]> err.no Git - linux-2.6/commitdiff
[MTD] pmcmsp-flash.c: kmalloc + memset conversion to k[cz]alloc
authorMariusz Kozlowski <m.kozlowski@tuxland.pl>
Tue, 31 Jul 2007 21:49:06 +0000 (23:49 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Wed, 1 Aug 2007 10:03:35 +0000 (11:03 +0100)
Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/maps/pmcmsp-flash.c

index 7e0377ec1c40df1255953176e9be4e842f04341c..02bde8c982ec68978de22a6a424286019189d4d9 100644 (file)
@@ -73,13 +73,16 @@ int __init init_msp_flash(void)
                return -ENXIO;
 
        printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt);
-       msp_flash = (struct mtd_info **)kmalloc(
-                       fcnt * sizeof(struct map_info *), GFP_KERNEL);
-       msp_parts = (struct mtd_partition **)kmalloc(
-                       fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
-       msp_maps = (struct map_info *)kmalloc(
-                       fcnt * sizeof(struct mtd_info), GFP_KERNEL);
-       memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));
+
+       msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
+       msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
+       msp_maps = kcalloc(fcnt, sizeof(struct mtd_info), GFP_KERNEL);
+       if (!msp_flash || !msp_parts || !msp_maps) {
+               kfree(msp_maps);
+               kfree(msp_parts);
+               kfree(msp_flash);
+               return -ENOMEM;
+       }
 
        /* loop over the flash devices, initializing each */
        for (i = 0; i < fcnt; i++) {
@@ -95,9 +98,8 @@ int __init init_msp_flash(void)
                        continue;
                }
 
-               msp_parts[i] = (struct mtd_partition *)kmalloc(
-                       pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
-               memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
+               msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition),
+                                      GFP_KERNEL);
 
                /* now initialize the devices proper */
                flash_name[5] = '0' + i;