From: maxin <john.maxin@nokia.com>
To: dedekind1@gmail.com
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>,
linux-mtd@lists.infradead.org,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] drivers: mtd: mtdswap: fix possible null dereference
Date: Fri, 20 May 2011 12:54:27 +0100 [thread overview]
Message-ID: <4DD65673.8080801@nokia.com> (raw)
In-Reply-To: <1305870365.2630.92.camel@localhost>
Hi Artem,
On 11-05-20 06:46 AM, ext Artem Bityutskiy wrote:
> On Wed, 2011-05-18 at 13:00 +0100, maxin wrote:
>> This patch fixes the possible null dereference of the variable "oinfo"
>
> Does this print makes sense? Which ECC? I think it should me something
> like "mtd% does not have OOB", mtd->index.
>
Thank you very much for reviewing the patch.I have updated the print message
as per your suggestion as it makes more sense for this case.
> Moreover, you should make the print consistent with the other prints
> which start with MTDSWAP_PREFIX.
>
I have updated the patch as per your comments.
Signed-off-by: Maxin B. John <john.maxin@nokia.com>
---
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index fed215c..62ddb3a 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1450,7 +1450,13 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
}
oinfo = mtd->ecclayout;
- if (!mtd->oobsize || !oinfo || oinfo->oobavail < MTDSWAP_OOBSIZE) {
+ if (!oinfo) {
+ printk(KERN_ERR "%s: mtd%d does not have OOB"
+ "\n", MTDSWAP_PREFIX, mtd->index);
+ return;
+ }
+
+ if (!mtd->oobsize || oinfo->oobavail < MTDSWAP_OOBSIZE) {
printk(KERN_ERR "%s: Not enough free bytes in OOB, "
"%d available, %zu needed.\n",
MTDSWAP_PREFIX, oinfo->oobavail, MTDSWAP_OOBSIZE);
next prev parent reply other threads:[~2011-05-20 9:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 12:00 [PATCH] drivers: mtd: mtdswap: fix possible null dereference maxin
2011-05-20 5:46 ` Artem Bityutskiy
2011-05-20 11:54 ` maxin [this message]
2011-05-20 10:20 ` Artem Bityutskiy
2011-05-20 13:22 ` maxin
2011-05-20 12:08 ` Artem Bityutskiy
2011-05-20 14:34 ` Maxin B. John
2011-05-20 12:10 ` Artem Bityutskiy
2011-05-20 14:44 ` Maxin B. John
2011-05-20 12:47 ` Artem Bityutskiy
2011-05-20 13:51 ` 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=4DD65673.8080801@nokia.com \
--to=john.maxin@nokia.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=jarkko.lavinen@nokia.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.