提交 60c01a97 编写于 作者: S Stefan Hajnoczi 提交者: Greg Kroah-Hartman

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: NStefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: NMarkus Grabner <grabner@icg.tugraz.at>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 407f3fd8
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册