staging: line6: alloc/free buffers in hw_params/hw_free
authorStefan Hajnoczi <stefanha@gmail.com>
Wed, 23 Nov 2011 08:20:45 +0000 (08:20 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 00:14:12 +0000 (16:14 -0800)
commit140e28b83c4a31831cbf293d9cab20c603821202
treed74a1c1ca636c668226fb1fdec4b7f0fccd1c376
parent3b08db37cb04a80dccac8c2d7b03690b5f179487
staging: line6: alloc/free buffers in hw_params/hw_free

It is unsafe to free buffers in line6_pcm_stop(), which is not allowed
to sleep, since urbs cannot be killed completely there and only
unlinked.  This means I/O may still be in progress and the URB
completion function still gets invoked.  This may result in memory
corruption when buffer_in is freed but I/O is still pending.

Additionally, line6_pcm_start() is not supposed to sleep so it should
not use kmalloc(GFP_KERNEL).

These issues can be resolved by performing buffer allocation/freeing in
the .hw_params/.hw_free callbacks instead.  The ALSA documentation also
recommends doing buffer allocation/freeing in these callbacks.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/line6/capture.c
drivers/staging/line6/pcm.c
drivers/staging/line6/playback.c