mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thiago Galesi" <thiagogalesi@gmail.com>
To: "Jim Ramsay" <kernel@jimramsay.com>
Cc: "Linux Kernel" <linux-kernel@vger.kernel.org>
Subject: Possible MTD bug in 2.6.15
Date: Wed, 19 Apr 2006 14:06:50 -0300	[thread overview]
Message-ID: <82ecf08e0604191006r26d8eab0n2c0a425809dea6ac@mail.gmail.com> (raw)
In-Reply-To: <4789af9e0604190949t42677b35mcba4ee57b92ffff9@mail.gmail.com>

Ok, a couple of comments/questions

1 - Wouldn't it be better to map all flash, and leave the unneeded
part as read only?

2 - Please follow  Documentation/SubmittingPatches format for sending
patches (especially the signed-off part and sending patches inline)

3 - No C++ style comments, please

Thiago


On 4/19/06, Jim Ramsay <kernel@jimramsay.com> wrote:
> We have an interesting problem with MTD and a flash chip on an
> embedded board.  The problem stems from the fact that due to hardware
> constraints we can only access up to 32M of address space on an
> attached flash device.  However, the actual part attached to the board
> is 64M.  Yes, I know this is not likely to happen, but it points at a
> kernel bug which will happen if you ever specify a MTD map->size which
> is less than the actual size of the CFI flash chip.
>
> When we specify the map->size as 32M (0x02000000) and do the CFI
> probe, the chip is properly detected, but then in gen_probe.c the
> following happens:
>
> - genprobe_ident_chips is run
>   - It sets cfi.chipshift based on the cfi.cfiq->DevSize, which gets
> properly set to 0x1a (64M flash chip).
>   - It then sets the local "max_chips" variable by shifting down
> map->size by this chipshift, which shifts our size (0x02000000 = 32M)
> down all the way to 0.
>   - Since 'max_chips' is zero, no memory is allocated for this chip,
> and the waitqueue is not initialized.  The will cause a kernel panic
> later, if you ever try to read from this chip.
>
> The routine completes and you are left with a seemingly valid MTD
> device.  However, if you ever try to read or write this device, the
> waitqueue is uninitialized, which causes a nasty kernel panic.
>
> My proposed fix is attached (a patch against 2.6.15).  After shifting
> the map->size down by cfi.chipshift, I just ensure that max_chips is
> at least one.  Does this seem like a reasonable fix?
>
> Note: Please CC my email address in reply, as I am not currently
> subscribed to the linux-kernel list.
>
> --
> Jim Ramsay
> "Me fail English?  That's unpossible!"
>
>
>

  reply	other threads:[~2006-04-19 17:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-19 16:49 Jim Ramsay
2006-04-19 17:06 ` Thiago Galesi [this message]
2006-04-19 17:43   ` Pekka Enberg
2006-05-30 12:30 ` David Woodhouse
     [not found] <1145723704.3524.TMDA@mail.tag.jimramsay.com>
2006-04-22 16:49 ` Fw: " Jim Ramsay
2006-04-22 17:08   ` Thiago Galesi
2006-04-23  3:48     ` Jim Ramsay
2006-04-23  7:45       ` Jörn Engel

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=82ecf08e0604191006r26d8eab0n2c0a425809dea6ac@mail.gmail.com \
    --to=thiagogalesi@gmail.com \
    --cc=kernel@jimramsay.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®