Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60c01a97 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Greg Kroah-Hartman
Browse files

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: default avatarStefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: default avatarMarkus Grabner <grabner@icg.tugraz.at>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 407f3fd8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -316,7 +316,10 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream,
	}
	/* -- [FD] end */

	line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
	/* 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) {
+5 −2
Original line number Diff line number Diff line
@@ -462,7 +462,10 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream,
	}
	/* -- [FD] end */

	line6pcm->buffer_out = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
	/* 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) {