From: "Jörn Engel" <joern@lazybastard.org>
To: Felix Fietkau <nbd@openwrt.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] block2mtd oops in erase function.
Date: Mon, 19 Feb 2007 22:20:41 +0000 [thread overview]
Message-ID: <20070219222041.GE7813@lazybastard.org> (raw)
In-Reply-To: <1171920579.4996.8.camel@celeron>
On Mon, 19 February 2007 22:29:39 +0100, Felix Fietkau wrote:
>
> Hi, I have a small fix for a crash that happened when I was using jffs2
> in combination with block2mtd.c
>
> In the erase function when checking the block to see if it's already
> erased, the limit is to be set to the page_address(page) + PAGE_SIZE,
> but because the variable has the type (ulong *), it gets set to
> PAGE_SIZE*sizeof(ulong), which makes the kernel oops when the page is
> very close to the end of RAM.
Good catch! What a twisted little piece of code you've found.
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
>
> --- linux.dev/drivers/mtd/devices/block2mtd.c.old 2007-02-18 14:08:59.519952312 +0100
> +++ linux.dev/drivers/mtd/devices/block2mtd.c 2007-02-18 14:09:04.219237912 +0100
> @@ -111,7 +111,7 @@
> if (IS_ERR(page))
> return PTR_ERR(page);
>
> - max = (u_long*)page_address(page) + PAGE_SIZE;
> + max = (u_long*) ((u8 *) page_address(page) + PAGE_SIZE);
> for (p=(u_long*)page_address(page); p<max; p++)
> if (*p != -1UL) {
> lock_page(page);
The proper fix would be to remove the cast instead of adding yet
another. I wonder when those got added.
Jörn
--
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu
next prev parent reply other threads:[~2007-02-19 22:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-19 21:29 [PATCH] block2mtd oops in erase function Felix Fietkau
2007-02-19 22:20 ` Jörn Engel [this message]
2007-02-19 22:30 ` Jörn Engel
2007-02-20 2:27 ` Felix Fietkau
2007-02-20 10:53 ` Jörn Engel
2007-02-20 21:35 ` Jason Lunz
2007-02-20 21:55 ` Jörn Engel
[not found] ` <20070221030254.GA11044@avocado.homenet>
2007-02-21 14:47 ` Jörn Engel
2007-02-21 15:42 ` Jason Lunz
2007-02-21 16:02 ` Jörn Engel
2007-02-21 20:26 ` Jason Lunz
2007-02-21 21:43 ` 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=20070219222041.GE7813@lazybastard.org \
--to=joern@lazybastard.org \
--cc=linux-mtd@lists.infradead.org \
--cc=nbd@openwrt.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