]> git.hungrycats.org Git - linux/commitdiff
mtd: pxa3xx_nand: NULL dereference in pxa3xx_nand_probe
authorDan Carpenter <error27@gmail.com>
Thu, 6 Jan 2011 14:05:36 +0000 (17:05 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 17 Feb 2011 23:15:09 +0000 (15:15 -0800)
commit 52d039fdaa78c5a9f9bc2940ad58d7ed76b8336d upstream.

"info->cmdset" gets dereferenced in __readid() so it needs to be
initialized earlier in the function.  This bug was introduced in
18c81b1828f8 "mtd: pxa3xx_nand: remove the flash info in driver
structure".

Reported-and-tested-by: Sven Neumann <s.neumann@raumfeld.com>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/mtd/nand/pxa3xx_nand.c

index 17f8518cc5eba1d1138912d579731d6e6cb14c36..ea2c288df3f6b31490f536202d737c323189c43c 100644 (file)
@@ -885,6 +885,7 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
        /* set info fields needed to __readid */
        info->read_id_bytes = (info->page_size == 2048) ? 4 : 2;
        info->reg_ndcr = ndcr;
+       info->cmdset = &default_cmdset;
 
        if (__readid(info, &id))
                return -ENODEV;
@@ -915,7 +916,6 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
 
        info->ndtr0cs0 = nand_readl(info, NDTR0CS0);
        info->ndtr1cs0 = nand_readl(info, NDTR1CS0);
-       info->cmdset = &default_cmdset;
 
        return 0;
 }