Skip to content

Commit 33baefe

Browse files
committed
ALSA: hda: Fix krealloc() with __GFP_ZERO usage
krealloc() doesn't work always properly with __GFP_ZERO flag as expected. For clearing the reallocated area, we need to clear explicitly instead. Reported-by: Joe Perches <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent fd48331 commit 33baefe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sound/hda/array.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ void *snd_array_new(struct snd_array *array)
2121
return NULL;
2222
if (array->used >= array->alloced) {
2323
int num = array->alloced + array->alloc_align;
24+
int oldsize = array->alloced * array->elem_size;
2425
int size = (num + 1) * array->elem_size;
2526
void *nlist;
2627
if (snd_BUG_ON(num >= 4096))
2728
return NULL;
28-
nlist = krealloc(array->list, size, GFP_KERNEL | __GFP_ZERO);
29+
nlist = krealloc(array->list, size, GFP_KERNEL);
2930
if (!nlist)
3031
return NULL;
32+
memset(nlist + oldsize, 0, size - oldsize);
3133
array->list = nlist;
3234
array->alloced = num;
3335
}

0 commit comments

Comments
 (0)