Skip to contentSkip to conversation

Staging: drivers: dma: ste_dma: Prefer kcalloc over kzalloc

PATCH In review Hatice ERTÜRK 2 participants 2 messages Feb 19, 2015

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

PATCH 1/1 Staging: drivers: dma: ste_dma: Prefer kcalloc over kzalloc

WARNING: Prefer kcalloc over kzalloc with multiply chackpatch.pl warning in ste_dma40.c

---
 drivers/dma/ste_dma40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
index 308795e..5cffef1 100644
@@ -3290,7 +3290,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 		base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4a);
 	}
 
-	base->phy_res = kzalloc(num_phy_chans * sizeof(struct d40_phy_res),
+	base->phy_res = kcalloc(num_phy_chans * sizeof(struct d40_phy_res),
 				GFP_KERNEL);
 	if (!base->phy_res)
 		goto failure;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 13 lines · Hatice ERTÜRK

WARNING: Prefer kcalloc over kzalloc with multiply chackpatch.pl warning in ste_dma40.c

---
 drivers/dma/ste_dma40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +0 -0
index 308795e..5cffef1 100644

drivers/dma/ste_dma40.c static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) · line 3294

Quoted 6 lines
drivers/dma/ste_dma40.c +1 -1
@@ -3290,7 +3290,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 		base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4a);
 	}
 
-	base->phy_res = kzalloc(num_phy_chans * sizeof(struct d40_phy_res),
+	base->phy_res = kcalloc(num_phy_chans * sizeof(struct d40_phy_res),
 				GFP_KERNEL);

The difference between kzalloc and kcalloc in a case like this is that with kzalloc the multiplication is done in the argument list, before the call, and with kcalloc the arguments to be multiplied are passed in separately, their size is checked, and then the multiplication is done if it will not overflow. In short, kcalloc takes three arguments, and your code provides only two. You need to be sure that you have compiled the code before submitting a patch.

julia

Quoted 12 lines
drivers/dma/ste_dma40.c +0 -0
 	if (!base->phy_res)
 		goto failure;
Signature · 8 lines
1.9.1

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1424376408-29567-1-git-send-email-haticeerturk27%40gmail.com.
For more options, visit https://groups.google.com/d/optout.