public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Chen Gong <g.chen@freescale.com>
Cc: linux-mtd@lists.infradead.org, viro@ftp.uk.linux.org
Subject: Re: [PATCH 3/3] [MTD] m25p80.c
Date: Mon, 15 Sep 2008 00:06:38 -0700	[thread overview]
Message-ID: <1221462398.3201.33.camel@macbook.infradead.org> (raw)
In-Reply-To: <1218080495-2653-4-git-send-email-g.chen@freescale.com>

On Thu, 2008-08-07 at 11:41 +0800, Chen Gong wrote:
> @@ -547,6 +550,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
>         u8                      code = OPCODE_RDID;
>         u8                      id[3];
>         u32                     jedec;
> +       u16                     ext_jedec;
>         struct flash_info       *info;
>  
>         /* JEDEC also defines an optional "extended device information"
	 * string for after vendor-specific data, after the three bytes
	 * we use here.  Supporting some chips might require using it.
	 */
	tmp = spi_write_then_read(spi, &code, 1, id, 3);
	if (tmp < 0) {
		DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n",
			spi->dev.bus_id, tmp);
		return NULL;
	}
	jedec = id[0];
	jedec = jedec << 8;
	jedec |= id[1];
>         jedec = jedec << 8;
>         jedec |= id[2];
>  
> +       ext_jedec = id[3] << 8 | id[4];
> +

You're trying to read off the end of the id[] array, which has only
three elements. And you didn't ask spi_write_then_read() to read that
many bytes _anyway_. And if you did... would it fail on chips which
don't have the extended device information?

Please test and send a fix, since this is already in the git tree.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

  parent reply	other threads:[~2008-09-15  7:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-07  3:41 [PATCH RESEND 0/4] m25p80 enhance patches Chen Gong
     [not found] ` <1218080495-2653-2-git-send-email-g.chen@freescale.com>
     [not found]   ` <1218080495-2653-3-git-send-email-g.chen@freescale.com>
     [not found]     ` <1218080495-2653-4-git-send-email-g.chen@freescale.com>
2008-08-07 13:31       ` [PATCH 3/3] [MTD] m25p80.c David Woodhouse
2008-09-15  7:06       ` David Woodhouse [this message]
2008-09-16  3:50         ` chen gong
  -- strict thread matches above, loose matches on Subject: below --
2008-06-20 11:04 [PATCH 1/3] [MTD] m25p80.c add a erase_block command to enhance erase operation Chen Gong
2008-06-20 11:04 ` [PATCH 2/3] [MTD] m25p80.c code cleanup Chen Gong
2008-06-20 11:04   ` [PATCH 3/3] [MTD] m25p80.c Chen Gong

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=1221462398.3201.33.camel@macbook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=g.chen@freescale.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=viro@ftp.uk.linux.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