Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stefan Hajnoczi and committed by
Greg Kroah-Hartman
60c01a97 407f3fd8

+10 -4
+5 -2
drivers/staging/line6/capture.c
··· 316 316 } 317 317 /* -- [FD] end */ 318 318 319 - line6pcm->buffer_in = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 320 - line6pcm->max_packet_size, GFP_KERNEL); 319 + /* We may be invoked multiple times in a row so allocate once only */ 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 325 if (!line6pcm->buffer_in) { 323 326 dev_err(line6pcm->line6->ifcdev,
+5 -2
drivers/staging/line6/playback.c
··· 462 462 } 463 463 /* -- [FD] end */ 464 464 465 - line6pcm->buffer_out = kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 466 - line6pcm->max_packet_size, GFP_KERNEL); 465 + /* We may be invoked multiple times in a row so allocate once only */ 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 471 if (!line6pcm->buffer_out) { 469 472 dev_err(line6pcm->line6->ifcdev,