aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@gmail.com>2011-12-09 20:12:27 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-09 22:26:09 -0500
commit60c01a977814788178362ff0e1a22dfbf106eede (patch)
treef2c4bde5eebe5e2265536d30062b809a8605e2fe
parent407f3fd8faf80f77c47ebda7501c6a8698d2f3a6 (diff)
staging: line6: fix memory leak in .hw_params()
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>
-rw-r--r--drivers/staging/line6/capture.c7
-rw-r--r--drivers/staging/line6/playback.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c
index ba441ed1a876..8f59ff3e7a17 100644
--- a/drivers/staging/line6/capture.c
+++ b/drivers/staging/line6/capture.c
@@ -316,8 +316,11 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream,
316 } 316 }
317 /* -- [FD] end */ 317 /* -- [FD] end */
318 318
319 line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 319 /* We may be invoked multiple times in a row so allocate once only */
320 line6pcm->max_packet_size, GFP_KERNEL); 320 if (!line6pcm->buffer_in)
321 line6pcm->buffer_in =
322 kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
323 line6pcm->max_packet_size, GFP_KERNEL);
321 324
322 if (!line6pcm->buffer_in) { 325 if (!line6pcm->buffer_in) {
323 dev_err(line6pcm->line6->ifcdev, 326 dev_err(line6pcm->line6->ifcdev,
diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c
index e495b32ed7df..ed1b9bd93ff8 100644
--- a/drivers/staging/line6/playback.c
+++ b/drivers/staging/line6/playback.c
@@ -462,8 +462,11 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream,
462 } 462 }
463 /* -- [FD] end */ 463 /* -- [FD] end */
464 464
465 line6pcm->buffer_out = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 465 /* We may be invoked multiple times in a row so allocate once only */
466 line6pcm->max_packet_size, GFP_KERNEL); 466 if (!line6pcm->buffer_out)
467 line6pcm->buffer_out =
468 kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
469 line6pcm->max_packet_size, GFP_KERNEL);
467 470
468 if (!line6pcm->buffer_out) { 471 if (!line6pcm->buffer_out) {
469 dev_err(line6pcm->line6->ifcdev, 472 dev_err(line6pcm->line6->ifcdev,