ARM: S3C: NAND: Check the existence of nr_map before copying
authorRamax Lo <ramaxlo@gmail.com>
Thu, 14 Jan 2010 02:15:05 +0000 (10:15 +0800)
committerBen Dooks <ben-linux@fluff.org>
Thu, 14 Jan 2010 02:25:44 +0000 (11:25 +0900)
Since the structure field nr_map is optional, we need to check whether the
chip number map is provided to avoid unexpected NULL pointer exception.

Signed-off-by: Ramax Lo <ramaxlo@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/plat-s3c/dev-nand.c

index 84808ccda70ebf8e528d6aa5e44ba36048b17a2c..a52fb6cf618fb93e77e1aae7a37a14a55efede77 100644 (file)
@@ -58,8 +58,8 @@ static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
                        return -ENOMEM;
        }
        
-       size = sizeof(int) * set->nr_chips;
-       if (size) {
+       if (set->nr_map && set->nr_chips) {
+               size = sizeof(int) * set->nr_chips;
                ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
                set->nr_map = ptr;