Skip to contentSkip to conversation

Staging: media: atomisp: Use kcalloc instead of kzalloc

PATCH New Srishti Sharma 1 participant 1 message Sep 14, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: media: atomisp: Use kcalloc instead of kzalloc

Use kcalloc instead of kzalloc to check for an overflow before multiplication. Done using the following semantic patch by coccinelle.

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

---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c +3 -1
index 6358216..2f4b71a 100644
@@ -235,7 +235,9 @@ sh_css_load_firmware(const char *fw_data,
 		sh_css_blob_info = NULL;
 	}
 
-	fw_minibuffer = kzalloc(sh_css_num_binaries * sizeof(struct fw_param), GFP_KERNEL);
+	fw_minibuffer = kcalloc(sh_css_num_binaries, sizeof(struct fw_param),
+				GFP_KERNEL);
+
 	if (fw_minibuffer == NULL)
 		return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
 
Signature · 1 line
2.7.4