ALSA: seq: fix kvmalloc_array() arguments order
authorDmitry Antipov <dmantipov@yandex.ru>
Thu, 21 Dec 2023 09:16:00 +0000 (12:16 +0300)
committerTakashi Iwai <tiwai@suse.de>
Fri, 29 Dec 2023 13:13:40 +0000 (14:13 +0100)
When compiling with gcc version 14.0.0 20231220 (experimental)
and W=1, I've noticed the following warning:

sound/core/seq/seq_memory.c: In function 'snd_seq_pool_init':
sound/core/seq/seq_memory.c:445:41: warning: 'kvmalloc_array' sizes specified with
'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  445 |         cellptr = kvmalloc_array(sizeof(struct snd_seq_event_cell), pool->size,
      |                                         ^~~~~~

Since 'n' and 'size' arguments of 'kvmalloc_array()' are multiplied
to calculate the final size, their actual order doesn't affect the
result and so this is not a bug. But it's still worth to fix it.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20231221091605.14660-1-dmantipov@yandex.ru
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq_memory.c

index b603bb93f896030130504e84eb29ff311ad393d1..e705e753811895f2aa4ff45e9bac9c3711bc8ac0 100644 (file)
@@ -442,7 +442,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
        if (snd_BUG_ON(!pool))
                return -EINVAL;
 
-       cellptr = kvmalloc_array(sizeof(struct snd_seq_event_cell), pool->size,
+       cellptr = kvmalloc_array(pool->size,
+                                sizeof(struct snd_seq_event_cell),
                                 GFP_KERNEL);
        if (!cellptr)
                return -ENOMEM;