Commit ffb73b08 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: info: Use kvzalloc() for a temporary write buffer

We used to use kmalloc (more exactly, krealloc()) for creating and
growing the temporary buffer for text proc write.  It can grow up to
16kB, and it's already a bit doubtful whether it's always safe to use
kmalloc().  With the recent addition of kvmalloc(), we can have a
better chance for succeed of memory allocation, so let's switch to
that new API.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c2c86a97
...@@ -344,12 +344,12 @@ static ssize_t snd_info_text_entry_write(struct file *file, ...@@ -344,12 +344,12 @@ static ssize_t snd_info_text_entry_write(struct file *file,
} }
} }
if (next > buf->len) { if (next > buf->len) {
char *nbuf = krealloc(buf->buffer, PAGE_ALIGN(next), char *nbuf = kvzalloc(PAGE_ALIGN(next), GFP_KERNEL);
GFP_KERNEL | __GFP_ZERO);
if (!nbuf) { if (!nbuf) {
err = -ENOMEM; err = -ENOMEM;
goto error; goto error;
} }
kvfree(buf->buffer);
buf->buffer = nbuf; buf->buffer = nbuf;
buf->len = PAGE_ALIGN(next); buf->len = PAGE_ALIGN(next);
} }
...@@ -427,7 +427,7 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file) ...@@ -427,7 +427,7 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
single_release(inode, file); single_release(inode, file);
kfree(data->rbuffer); kfree(data->rbuffer);
if (data->wbuffer) { if (data->wbuffer) {
kfree(data->wbuffer->buffer); kvfree(data->wbuffer->buffer);
kfree(data->wbuffer); kfree(data->wbuffer);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment