Skip to content

Commit

Permalink
ALSA: info: Use kvzalloc() for a temporary write buffer
Browse files Browse the repository at this point in the history
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: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed May 23, 2017
1 parent c2c86a9 commit ffb73b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sound/core/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ static ssize_t snd_info_text_entry_write(struct file *file,
}
}
if (next > buf->len) {
char *nbuf = krealloc(buf->buffer, PAGE_ALIGN(next),
GFP_KERNEL | __GFP_ZERO);
char *nbuf = kvzalloc(PAGE_ALIGN(next), GFP_KERNEL);
if (!nbuf) {
err = -ENOMEM;
goto error;
}
kvfree(buf->buffer);
buf->buffer = nbuf;
buf->len = PAGE_ALIGN(next);
}
Expand Down Expand Up @@ -427,7 +427,7 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
single_release(inode, file);
kfree(data->rbuffer);
if (data->wbuffer) {
kfree(data->wbuffer->buffer);
kvfree(data->wbuffer->buffer);
kfree(data->wbuffer);
}

Expand Down

0 comments on commit ffb73b0

Please sign in to comment.