Skip to content

Commit

Permalink
staging: line6: fix memory leak in .hw_params()
Browse files Browse the repository at this point in the history
The .hw_params() pcm callback can be invoked multiple times in a row.
Ensure that the URB data buffer is only allocated once.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Markus Grabner <grabner@icg.tugraz.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Stefan Hajnoczi authored and Greg Kroah-Hartman committed Dec 10, 2011
1 parent 407f3fd commit 60c01a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions drivers/staging/line6/capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,11 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream,
}
/* -- [FD] end */

line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
line6pcm->max_packet_size, GFP_KERNEL);
/* We may be invoked multiple times in a row so allocate once only */
if (!line6pcm->buffer_in)
line6pcm->buffer_in =
kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
line6pcm->max_packet_size, GFP_KERNEL);

if (!line6pcm->buffer_in) {
dev_err(line6pcm->line6->ifcdev,
Expand Down
7 changes: 5 additions & 2 deletions drivers/staging/line6/playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,11 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream,
}
/* -- [FD] end */

line6pcm->buffer_out = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
line6pcm->max_packet_size, GFP_KERNEL);
/* We may be invoked multiple times in a row so allocate once only */
if (!line6pcm->buffer_out)
line6pcm->buffer_out =
kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
line6pcm->max_packet_size, GFP_KERNEL);

if (!line6pcm->buffer_out) {
dev_err(line6pcm->line6->ifcdev,
Expand Down

0 comments on commit 60c01a9

Please sign in to comment.