mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
ALSA: Use krealloc() in possible places
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
08ef79490d
commit
3101ba035c
@ -626,10 +626,10 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (params->buffer_size != runtime->buffer_size) {
|
||||
newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
|
||||
newbuf = krealloc(runtime->buffer, params->buffer_size,
|
||||
GFP_KERNEL);
|
||||
if (!newbuf)
|
||||
return -ENOMEM;
|
||||
kfree(runtime->buffer);
|
||||
runtime->buffer = newbuf;
|
||||
runtime->buffer_size = params->buffer_size;
|
||||
runtime->avail = runtime->buffer_size;
|
||||
@ -653,10 +653,10 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (params->buffer_size != runtime->buffer_size) {
|
||||
newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
|
||||
newbuf = krealloc(runtime->buffer, params->buffer_size,
|
||||
GFP_KERNEL);
|
||||
if (!newbuf)
|
||||
return -ENOMEM;
|
||||
kfree(runtime->buffer);
|
||||
runtime->buffer = newbuf;
|
||||
runtime->buffer_size = params->buffer_size;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user