diff mbox series

[next] ALSA: sc6000: Fix incorrect sizeof operator

Message ID 20210720161707.74197-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series [next] ALSA: sc6000: Fix incorrect sizeof operator | expand

Commit Message

Colin King July 20, 2021, 4:17 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Static analysis is warning that the sizeof being used is should be
of *vport and not vport. Although these are the same size it is not
a portable assumption to assume this is true for all cases.  Fix this
by using sizeof(*vport).

Addresses-Coverity: ("Sizeof not portable")
Fixes: 111601ff76e9 ("ALSA: sc6000: Allocate resources with device-managed APIs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 sound/isa/sc6000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai July 20, 2021, 4:22 p.m. UTC | #1
On Tue, 20 Jul 2021 18:17:07 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> Static analysis is warning that the sizeof being used is should be
> of *vport and not vport. Although these are the same size it is not
> a portable assumption to assume this is true for all cases.  Fix this
> by using sizeof(*vport).
> 
> Addresses-Coverity: ("Sizeof not portable")
> Fixes: 111601ff76e9 ("ALSA: sc6000: Allocate resources with device-managed APIs")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks.  I have another patch to drop this allocation (it's just a
pointer, so no need for kmalloc, really), but since your patch is
correct, I'll rebase on yours.


Takashi
diff mbox series

Patch

diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c
index 6236c4fa766a..44c05b55fc15 100644
--- a/sound/isa/sc6000.c
+++ b/sound/isa/sc6000.c
@@ -552,7 +552,7 @@  static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
 
 
 	err = snd_devm_card_new(devptr, index[dev], id[dev], THIS_MODULE,
-				sizeof(vport), &card);
+				sizeof(*vport), &card);
 	if (err < 0)
 		return err;