diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-07-12 08:05:16 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-07-12 08:05:16 +0200 |
commit | 3101ba035ca9ba92f6cec7fd37348646b7a5cb61 (patch) | |
tree | 478b2181515e980f60707ac2bf4b21e65cbc0b4c /sound/pci | |
parent | 08ef79490dad6b88010e94795cf9f89b018ed504 (diff) |
ALSA: Use krealloc() in possible places
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 45b4a8d70e0..4afc6fcf0cd 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4957,17 +4957,14 @@ void *snd_array_new(struct snd_array *array) { if (array->used >= array->alloced) { int num = array->alloced + array->alloc_align; + int size = (num + 1) * array->elem_size; void *nlist; if (snd_BUG_ON(num >= 4096)) return NULL; - nlist = kcalloc(num + 1, array->elem_size, GFP_KERNEL); + nlist = krealloc(array->list, size, GFP_KERNEL); if (!nlist) return NULL; - if (array->list) { - memcpy(nlist, array->list, - array->elem_size * array->alloced); - kfree(array->list); - } + memset(nlist, 0, size - array->alloced * array->elem_size); array->list = nlist; array->alloced = num; } |