Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: sound/isa/gus: Correct code taking the size of a pointer

sizeof(share_id) is just the size of the pointer. On the other hand,
block->share_id is an array, so its size seems more appropriate.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
expression f;
type T;
@@

*f(...,(T)x,...)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Julia Lawall and committed by
Takashi Iwai
0d64b568 84a3bd06

+2 -1
+2 -1
sound/isa/gus/gus_mem.c
··· 127 127 !share_id[2] && !share_id[3]) 128 128 return NULL; 129 129 for (block = alloc->first; block; block = block->next) 130 - if (!memcmp(share_id, block->share_id, sizeof(share_id))) 130 + if (!memcmp(share_id, block->share_id, 131 + sizeof(block->share_id))) 131 132 return block; 132 133 return NULL; 133 134 }