From: Brian Norris <computersforpeace@gmail.com>
To: Wei.Yang@windriver.com
Cc: linux-mtd@lists.infradead.org, w90p710@gmail.com, dedekind1@gmail.com
Subject: Re: [PATCH mtd-utils] libmtd: don't ignore "region index" parameter in mtd_regioninfo()
Date: Tue, 4 Nov 2014 19:01:40 -0800 [thread overview]
Message-ID: <20141105030140.GL23619@ld-irv-0074> (raw)
In-Reply-To: <20140915174821.GB14832@ld-irv-0074>
On Mon, Sep 15, 2014 at 10:48:21AM -0700, Brian Norris wrote:
> ioctl(MEMGETREGIONINFO) has one input parameter (regionindex) and three
> output parameters (info about the erase region). There are two problems
> in mtdinfo/libmtd here:
>
> 1. mtdinfo.c doesn't initialize its region_info_user struct, instead
> passing uninitialized data to mtd_regioninfo()
>
> 2. mtd_regioninfo() fails to utilize the 'regidx' parameter to fill out
> the regionindex parameter properly, so the garbage from mtdinfo.c is
> propagated to the ioctl()
>
> This means that mtdinfo will continuously probe the same (possibly
> out-of-range) erase region, instead of looping over the valid regions.
>
> Let's fix this in the mtd_regioninfo() helper, and at the same time,
> let's zero out the mtdinfo.c buffer, as an additional precaution to keep
> from using uninitialized data.
>
> Initial error report from Yang, when running "mtdinfo /dev/mtd0" on a
> 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
>
> Reported-by: Yang Wei <Wei.Yang@windriver.com>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Pushed to mtd-utils.git.
Brian
prev parent reply other threads:[~2014-11-05 3:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20141105030140.GL23619@ld-irv-0074 \
--to=computersforpeace@gmail.com \
--cc=Wei.Yang@windriver.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=w90p710@gmail.com \
/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