All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: mtd: mtdswap: fix possible null dereference
@ 2011-05-18 12:00 maxin
  2011-05-20  5:46 ` Artem Bityutskiy
  0 siblings, 1 reply; 11+ messages in thread
From: maxin @ 2011-05-18 12:00 UTC (permalink / raw)
  To: linux-mtd; +Cc: Jarkko Lavinen, David Woodhouse


This patch fixes the possible null dereference of the variable "oinfo"
Thanks to Coverity for spotting this.

Signed-off-by: Maxin B. John <john.maxin@nokia.com>
---
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index fed215c..863987c 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1450,7 +1450,12 @@ 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 "Not enough free bytes available for ECC");
+		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);

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-05-20 13:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.