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>
diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c
index ba441ed..8f59ff3 100644
--- a/drivers/staging/line6/capture.c
+++ b/drivers/staging/line6/capture.c
@@ -316,8 +316,11 @@
 	}
 	/* -- [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,
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 @@
 	}
 	/* -- [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,