summaryrefslogtreecommitdiff
path: root/ubi-utils/mtdinfo.c
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2011-08-09 14:36:42 -0700
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-08-16 17:12:17 +0300
commit8faa32ae07b0fce0636f6e57d9dd4a93db0ebc13 (patch)
tree688669caa72d30d330741de0265e76657344936c /ubi-utils/mtdinfo.c
parentf1fe865bc582649c85f4ece1baf2905f877d3964 (diff)
mtdinfo: don't open NULL pointer when getting region_info with `-a'
This "fixes" a regression found in: commit 266061ebd5d72391f0a0e831b018e8fc7fea68a1 mtdinfo: add regioninfo/eraseblock map display On certain flash (NOR flash that have eraseblock region info), `mtdinfo -a' tries to open the MTD node file, for use with the ioctl MEMGETREGIONINFO; however, we didn't supply a device node path to `mtdinfo -a', so it's using NULL, resulting in errors like: mtdinfo: error!: couldn't open MTD dev: (null) error 14 (Bad address) For now, we can just skip dumping region_info with the `-a' flag. If we find a better way to do this (e.g., export via sysfs, find device nodes via automatic routines, etc.), then we can kill the workaround and this FIXME should be removed. The regression was first reported at: http://lists.infradead.org/pipermail/linux-mtd/2011-July/037232.html The result of recent changes is that we cannot get region_info for devices via the `--all' option. We add a note in the help message warning that mtdinfo may find more info when given a device patch, e.g., /dev/mtdX. Reported-by: Brian Foster <brian.foster@maxim-ic.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'ubi-utils/mtdinfo.c')
-rw-r--r--ubi-utils/mtdinfo.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index e72d69e..b4a2f4c 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -58,6 +58,8 @@ static const char optionsstr[] =
" on this MTD device\n"
"-M, --map print eraseblock map\n"
"-a, --all print information about all MTD devices\n"
+" Note: `--all' may give less info per device\n"
+" than, e.g., `mtdinfo /dev/mtdX'\n"
"-h, --help print help message\n"
"-V, --version print program version";
@@ -239,8 +241,14 @@ static void print_region_info(const struct mtd_dev_info *mtd)
region_info_t reginfo;
int r, fd;
- /* If we don't have any region info, just return */
- if (!args.map && mtd->region_cnt == 0)
+ /*
+ * If we don't have any region info, just return
+ *
+ * FIXME: We can't get region_info (via ioctl) without having the MTD
+ * node path. This is a problem for `mtdinfo -a', for example,
+ * since it doesn't provide any filepath information.
+ */
+ if (!args.node || (!args.map && mtd->region_cnt == 0))
return;
/* First open the device so we can query it */