mtd: mtdswap: fix possible null dereference
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue May 24 21:59:07 EDT 2011
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=8d8f26e19cae48541b824f164021e1ff05067f8c
Commit: 8d8f26e19cae48541b824f164021e1ff05067f8c
Parent: 5c8d2607756a63ddf5b2f2dd368851b8febe4e72
Author: Maxin B. John <john.maxin at nokia.com>
AuthorDate: Fri May 20 15:44:10 2011 +0100
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Wed May 25 02:11:44 2011 +0100
mtd: mtdswap: fix possible null dereference
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 at nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/mtdswap.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index fed215c..fd78853 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);
More information about the linux-mtd-cvs
mailing list