Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4fb4caa639a27a3cb0b3bfbf2041524af43efff9
Commit:     4fb4caa639a27a3cb0b3bfbf2041524af43efff9
Parent:     40562f812bb4b0211da07ad1927af030b089d3d3
Author:     Mariusz Kozlowski <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 31 23:49:06 2007 +0200
Committer:  David Woodhouse <[EMAIL PROTECTED]>
CommitDate: Wed Aug 1 11:03:35 2007 +0100

    [MTD] pmcmsp-flash.c: kmalloc + memset conversion to k[cz]alloc
    
    Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]>
    Signed-off-by: David Woodhouse <[EMAIL PROTECTED]>
---
 drivers/mtd/maps/pmcmsp-flash.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index 7e0377e..02bde8c 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to