From: Janani Ravichandran Date: Tue, 9 Feb 2016 22:06:27 +0000 (-0500) Subject: staging: rdma: Use kcalloc instead of kzalloc X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5a267953baca23c49f78a2e365aa0f44f762b0c1;p=linux-beck.git staging: rdma: Use kcalloc instead of kzalloc 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c index 7dc5bae220e0..e569f9f456c5 100644 --- a/drivers/staging/rdma/hfi1/efivar.c +++ b/drivers/staging/rdma/hfi1/efivar.c @@ -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) {