Skip to content

Commit

Permalink
mtd: mtdswap: fix possible null dereference
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Maxin B. John authored and David Woodhouse committed May 25, 2011
1 parent 5c8d260 commit 8d8f26e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/mtd/mtdswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8d8f26e

Please sign in to comment.