Skip to contentSkip to conversation

staging: rdma: Use kcalloc instead of kzalloc

PATCH New Janani Ravichandran 1 participant 1 message Feb 9, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 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.

---
Changes since v3:
* This patch makes changes since Greg's tree rather than my previous patch

 drivers/staging/rdma/hfi1/efivar.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rdma/hfi1/efivar.c +1 -2
index 7dc5bae..e569f9f 100644
@@ -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) {
Signature · 1 line
2.5.0