Patchwork [RESEND] mtd: onenand: onenand_base: check for region != NULL

login
register
mail settings
Submitter john.maxin@nokia.com
Date May 6, 2011, 9:17 a.m.
Message ID <77DFD0EF40BC5042BB7221A1EFFF7570A167@008-AM1MPN1-021.mgdnok.nokia.com>
Download mbox | patch
Permalink /patch/94348/
State New
Headers show

Comments

john.maxin@nokia.com - May 6, 2011, 9:17 a.m.
Coverity has reported that inside the function "onenand_block_by_block_erase()" 
in onenand_base.c, we should add a check to prevent the incrementing of 
possible NULL value for "region"

Signed-off-by: Maxin B. John <john.maxin@nokia.com>
---
Artem Bityutskiy - May 6, 2011, 7:04 p.m.
On Fri, 2011-05-06 at 09:17 +0000, john.maxin@nokia.com wrote:
> Coverity has reported that inside the function "onenand_block_by_block_erase()" 
> in onenand_base.c, we should add a check to prevent the incrementing of 
> possible NULL value for "region"
> 
> Signed-off-by: Maxin B. John <john.maxin@nokia.com>

This patch is not against the upstream kernel, I could not apply it. But
it is trivial enough and I could manually apply it. Pushed to
l2-mtd-2.6.git tree, thanks.

Patch

diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 56a8b20..fd659f8 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2424,7 +2424,7 @@  static int onenand_block_by_block_erase(struct mtd_info *mtd,
                len -= block_size;
                addr += block_size;

-               if (addr == region_end) {
+               if (region && addr == region_end) {
                        if (!len)
                                break;
                        region++;