From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Florin Malita" <fmalita@gmail.com>
Cc: dedekind@infradead.org, linux-mtd@lists.infradead.org,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] UBI: dereference after kfree in create_vtbl
Date: Sat, 5 May 2007 03:12:02 +0530 [thread overview]
Message-ID: <a781481a0705041442h37453fb6k26d04eb5356e9dc0@mail.gmail.com> (raw)
In-Reply-To: <463A04A5.5030103@gmail.com>
Hi Florin, Artem,
On 5/3/07, Florin Malita <fmalita@gmail.com> wrote:
> [...]
> write_error:
> - kfree(new_seb);
> - /* May be this physical eraseblock went bad, try to pick another one */
> - if (++tries <= 5) {
> + /* Maybe this physical eraseblock went bad, try to pick another one */
> + if (++tries <= 5)
> err = ubi_scan_add_to_list(si, new_seb->pnum, new_seb->ec,
> &si->corr);
> - if (!err)
> - goto retry;
> - }
> + kfree(new_seb);
> + if (!err)
> + goto retry;
Eeks ... no, wait. You found a (two, actually) bug alright, but fixed
it wrong. When we fail a write, we *must* add it to the corrupted list
and _then_ attempt to retry. So, the "if (++tries <= 5)" applies to
"if (!err) goto retry;" and not to the ubi_scan_add_to_list(). The
difference is quite subtle here ...
The correct fix should actually be as follows: (Artem, this is diffed
on the original vtbl.c)
---
Fix write_error logic in drivers/mtd/ubi/vtbl.c:create_vtbl(). On a
write failure, we add the corrupted physical eraseblock to the
corrupted list, and then attempt to retry (upto a maximum of 5 times).
Also, fix an oops by pushing kfree(new_seb) below after dereferencing
it for ubi_scan_add_to_list().
Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Signed-off-by: Florin Malita <fmalita@gmail.com>
---
drivers/mtd/ubi/vtbl.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
---
diff -ruNp a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
--- a/drivers/mtd/ubi/vtbl.c 2007-04-20 18:42:17.000000000 +0530
+++ b/drivers/mtd/ubi/vtbl.c 2007-05-05 03:01:32.000000000 +0530
@@ -317,14 +317,12 @@ retry:
return err;
write_error:
- kfree(new_seb);
/* May be this physical eraseblock went bad, try to pick another one */
- if (++tries <= 5) {
- err = ubi_scan_add_to_list(si, new_seb->pnum, new_seb->ec,
- &si->corr);
+ err = ubi_scan_add_to_list(si, new_seb->pnum, new_seb->ec, &si->corr);
+ kfree(new_seb);
+ if (++tries <= 5)
if (!err)
goto retry;
- }
out_free:
ubi_free_vid_hdr(ubi, vid_hdr);
return err;
next prev parent reply other threads:[~2007-05-04 21:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-03 15:49 Florin Malita
2007-05-04 7:17 ` Artem Bityutskiy
2007-05-04 21:42 ` Satyam Sharma [this message]
2007-05-04 23:22 ` Florin Malita
2007-05-05 3:55 ` Satyam Sharma
2007-05-05 7:55 ` Artem Bityutskiy
2007-05-05 12:26 ` Satyam Sharma
2007-05-05 13:18 ` Artem Bityutskiy
2007-05-05 13:48 ` Satyam Sharma
2007-05-05 13:59 ` Artem Bityutskiy
2007-05-05 15:00 ` Satyam Sharma
2007-05-05 12:09 ` Artem Bityutskiy
2007-05-05 13:32 ` Satyam Sharma
2007-05-05 13:48 ` Artem Bityutskiy
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=a781481a0705041442h37453fb6k26d04eb5356e9dc0@mail.gmail.com \
--to=satyam.sharma@gmail.com \
--cc=dedekind@infradead.org \
--cc=fmalita@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.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®