Staging: ccree: Use kcalloc instead of kzalloc
authorSrishti Sharma <srishtishar@gmail.com>
Thu, 14 Sep 2017 12:48:13 +0000 (18:18 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Sep 2017 10:00:07 +0000 (12:00 +0200)
Use kcalloc instead of kzalloc to check for overflow before
multiplication. Done using the following semantic patch by
coccinelle.

http://coccinelle.lip6.fr/rules/kzalloc.cocci

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ccree/ssi_sysfs.c

index 0655658..f7e0c50 100644 (file)
@@ -376,7 +376,7 @@ static int sys_init_dir(struct sys_dir *sys_dir, struct ssi_drvdata *drvdata,
                return -ENOMEM;
        /* allocate memory for directory's attributes list */
        sys_dir->sys_dir_attr_list =
-               kzalloc(sizeof(struct attribute *) * (num_of_attrs + 1),
+               kcalloc(num_of_attrs + 1, sizeof(struct attribute *),
                        GFP_KERNEL);
 
        if (!(sys_dir->sys_dir_attr_list)) {