From: "Brian Norris" <computersforpeace@gmail.com>
To: "Artem Bityutskiy" <dedekind1@gmail.com>
Cc: brian.foster@maxim-ic.com, Mike Frysinger <vapier@gentoo.org>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org
Subject: [PATCH] mtdinfo: don't open NULL pointer when getting region_info with `-a'
Date: Thu, 4 Aug 2011 10:47:31 -0700 [thread overview]
Message-ID: <1312480051-19208-1-git-send-email-computersforpeace@gmail.com> (raw)
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
Reported-by: Brian Foster <brian.foster@maxim-ic.com>
CC: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
ubi-utils/mtdinfo.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index e72d69e..f2fcd38 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -239,8 +239,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 */
--
1.7.0.4
next reply other threads:[~2011-08-04 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 17:47 Brian Norris [this message]
2011-08-04 22:36 ` [PATCH] mtdinfo: don't open NULL pointer when getting region_info with `-a' Mike Frysinger
2011-08-05 7:29 ` Brian Foster
2011-08-05 22:59 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312480051-19208-1-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=brian.foster@maxim-ic.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox