]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: rdma: Use kcalloc instead of kzalloc
authorJanani Ravichandran <janani.rvchndrn@gmail.com>
Tue, 9 Feb 2016 22:06:27 +0000 (17:06 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Feb 2016 01:43:09 +0000 (17:43 -0800)
Use kcalloc rather than kzalloc when multiplied by size to prevent
integer overflows. This change also makes code nicer to read.

Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rdma/hfi1/efivar.c

index 7dc5bae220e08539ee6da40316262be5dc6052e5..e569f9f456c5b5f6c201aaa0b3cb52625e0539be 100644 (file)
@@ -83,8 +83,7 @@ static int read_efi_var(const char *name, unsigned long *size,
        if (!efi_enabled(EFI_RUNTIME_SERVICES))
                return -EOPNOTSUPP;
 
-       uni_name = kzalloc(sizeof(efi_char16_t) * (strlen(name) + 1),
-                          GFP_KERNEL);
+       uni_name = kcalloc(strlen(name) + 1, sizeof(efi_char16_t), GFP_KERNEL);
        temp_buffer = kzalloc(EFI_DATA_SIZE, GFP_KERNEL);
 
        if (!uni_name || !temp_buffer) {