All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] mtdinfo: Initialize reginfo variable before invoking mtd_regioninfo
@ 2014-08-06  3:00 Wei.Yang
  2014-09-15 17:31 ` Brian Norris
  0 siblings, 1 reply; 5+ messages in thread
From: Wei.Yang @ 2014-08-06  3:00 UTC (permalink / raw)
  To: computersforpeace, dedekind1; +Cc: linux-mtd, wei.yang, w90p710

From: Yang Wei <Wei.Yang@windriver.com>

If not initializing this variable, its value would be random. So
once the value of the regionindex field of region_info_user structure
is greater than mtd->numeraseregions. ioctl,which comes with MEMGETREGIONINFO,
would return -EINVAL

Signed-off-by: Yang Wei <Wei.Yang@windriver.com>
---
 ubi-utils/mtdinfo.c |    2 ++
 1 file changed, 2 insertions(+)

		Hi Guys,

		I got the following errors when running "mtdinfo /dev/mtd0" on Cavium 6100 board,


		root@CN61XX:~# mtdinfo /dev/mtd0
		mtd0
		Name:                           phys_mapped_flash
		Type:                           nor
		Eraseblock size:                65536 bytes, 64.0 KiB
		Amount of eraseblocks:          128 (8388608 bytes, 8.0 MiB)
		Minimum input/output unit size: 1 byte
		Sub-page size:                  1 byte
		Additional erase regions:       0
		Character device major/minor:   90:0
		Bad blocks are allowed:         false
		Device is writable:             true
		libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 0
		        error 22 (Invalid argument)
		Eraseblock region 0:  info is unavailable
		libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 1
		        error 22 (Invalid argument)
		Eraseblock region 1:  info is unavailable

		This patch is to fix the above errors. I have already verified it

		root@CN61XX:~# ./mtdinfo /dev/mtd0
		mtd0
		Name:                           phys_mapped_flash
		Type:                           nor
		Eraseblock size:                65536 bytes, 64.0 KiB
		Amount of eraseblocks:          128 (8388608 bytes, 8.0 MiB)
		Minimum input/output unit size: 1 byte
		Sub-page size:                  1 byte
		Additional erase regions:       0
		Character device major/minor:   90:0
		Bad blocks are allowed:         false
		Device is writable:             true
		Eraseblock region 0:  offset: 0 size: 0x10000 numblocks: 0x7f
		Eraseblock region 1:  offset: 0 size: 0x10000 numblocks: 0x7f

		root@CN61XX:~#


diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index 5ac95aa..a70db00 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -253,6 +253,8 @@ static void print_region_info(const struct mtd_dev_info *mtd)
 	if (!args.node || (!args.map && mtd->region_cnt == 0))
 		return;
 
+	memset(&reginfo, 0, sizeof(region_info_t));
+
 	/* First open the device so we can query it */
 	fd = open(args.node, O_RDONLY | O_CLOEXEC);
 	if (fd == -1) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-05  3:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06  3:00 [PATCH v1] mtdinfo: Initialize reginfo variable before invoking mtd_regioninfo Wei.Yang
2014-09-15 17:31 ` Brian Norris
2014-09-15 17:48   ` [PATCH mtd-utils] libmtd: don't ignore "region index" parameter in mtd_regioninfo() Brian Norris
2014-09-16 15:26     ` Artem Bityutskiy
2014-11-05  3:01     ` Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.