Skip to contentSkip to conversation

ALSA: ctxfi: change dao_set_input functions from kzalloc to kcalloc

PATCH Applied Ethan Carter Edwards 3 participants 3 messages Mar 8, 2025 – Mar 10, 2025 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: ctxfi: change dao_set_input functions from kzalloc to kcalloc

We are trying to get rid of all multiplications from allocation functions to prevent potential integer overflows. Here the multiplication is probably safe, but using kcalloc() is more appropriate and improves readability. This patch has no effect on runtime behavior.

---
 sound/pci/ctxfi/ctdaio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/ctxfi/ctdaio.c +2 -2
index 9993b02d2968c6c6858475f7ab98d4e90e7ffe2a..806c4d7543877ed74f8ec2dd894cf6b76af6f314 100644
@@ -159,7 +159,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input)
 	struct daio *daio = &dao->daio;
 	int i;
 
-	entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL);
+	entry = kcalloc(daio->rscl.msr, sizeof(*entry), GFP_KERNEL);
 	if (!entry)
 		return -ENOMEM;
 
@@ -188,7 +188,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input)
 	struct daio *daio = &dao->daio;
 	int i;
 
-	entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL);
+	entry = kcalloc(daio->rscr.msr, sizeof(*entry), GFP_KERNEL);
 	if (!entry)
 		return -ENOMEM;
 

---
base-commit: 0a2f889128969dab41861b6e40111aa03dc57014
change-id: 20250308-ctdaio-kzalloc-fcf47b8c4f74

Best regards,

Signature · 1 line
Ethan Carter Edwards <[email protected]>
Applied
#2 lore raw
In reply to Ethan Carter Edwards
Quoted 11 lines · Ethan Carter Edwards

We are trying to get rid of all multiplications from allocation functions to prevent potential integer overflows. Here the multiplication is probably safe, but using kcalloc() is more appropriate and improves readability. This patch has no effect on runtime behavior.

Thanks, applied now.

Takashi