[alsa-devel] [PATCH 3/5] ASoC: dapm: Use kcalloc() in	snd_soc_dapm_new_widgets()
    SF Markus Elfring 
    elfring at users.sourceforge.net
       
    Thu Aug 10 15:03:19 CEST 2017
    
    
  
From: Markus Elfring <elfring at users.sourceforge.net>
Date: Thu, 10 Aug 2017 14:30:48 +0200
* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".
  This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
 sound/soc/soc-dapm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index e673961210e6..3fa9f023bff7 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3027,9 +3027,9 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
 			continue;
 
 		if (w->num_kcontrols) {
-			w->kcontrols = kzalloc(w->num_kcontrols *
-						sizeof(struct snd_kcontrol *),
-						GFP_KERNEL);
+			w->kcontrols = kcalloc(w->num_kcontrols,
+					       sizeof(*w->kcontrols),
+					       GFP_KERNEL);
 			if (!w->kcontrols) {
 				mutex_unlock(&card->dapm_mutex);
 				return -ENOMEM;
-- 
2.14.0
    
    
More information about the Alsa-devel
mailing list