summaryrefslogtreecommitdiff
path: root/drivers/staging/line6/playback.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@gmail.com>2011-12-10 01:12:27 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-10 03:26:09 (GMT)
commit60c01a977814788178362ff0e1a22dfbf106eede (patch)
treef2c4bde5eebe5e2265536d30062b809a8605e2fe /drivers/staging/line6/playback.c
parent407f3fd8faf80f77c47ebda7501c6a8698d2f3a6 (diff)
downloadlinux-fsl-qoriq-60c01a977814788178362ff0e1a22dfbf106eede.tar.xz
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>
Diffstat (limited to 'drivers/staging/line6/playback.c')
-rw-r--r--drivers/staging/line6/playback.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c
index e495b32..ed1b9bd 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,
}
/* -- [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,