]> www.infradead.org Git - mtd-utils.git/commit
mtdinfo: don't open NULL pointer when getting region_info with `-a'
authorBrian Norris <computersforpeace@gmail.com>
Tue, 9 Aug 2011 21:36:42 +0000 (14:36 -0700)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Tue, 16 Aug 2011 14:12:17 +0000 (17:12 +0300)
commit8faa32ae07b0fce0636f6e57d9dd4a93db0ebc13
tree688669caa72d30d330741de0265e76657344936c
parentf1fe865bc582649c85f4ece1baf2905f877d3964
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>
ubi-utils/mtdinfo.c