mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 15:47:36 +00:00
ALSA: usb-audio: Fix NULL dererence at error path
commit 568be8aaf8
upstream.
At an error path to release URB buffers and contexts, the driver might
hit a NULL dererence for u->urb pointer, when u->buffer_size has been
already set but the actual URB allocation failed.
Fix it by adding the NULL check of urb. Also, make sure that
buffer_size is cleared after the error path or the close.
Cc: <stable@vger.kernel.org>
Reported-by: Sabri N. Ferreiro <snferreiro1@gmail.com>
Link: https://lore.kernel.org/r/CAKG+3NRjTey+fFfUEGwuxL-pi_=T4cUskYG9OzpzHytF+tzYng@mail.gmail.com
Link: https://lore.kernel.org/r/20220930100129.19445-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e4442410f7
commit
d4d02ac102
1 changed files with 2 additions and 1 deletions
|
@ -93,12 +93,13 @@ static inline unsigned get_usb_high_speed_rate(unsigned int rate)
|
||||||
*/
|
*/
|
||||||
static void release_urb_ctx(struct snd_urb_ctx *u)
|
static void release_urb_ctx(struct snd_urb_ctx *u)
|
||||||
{
|
{
|
||||||
if (u->buffer_size)
|
if (u->urb && u->buffer_size)
|
||||||
usb_free_coherent(u->ep->chip->dev, u->buffer_size,
|
usb_free_coherent(u->ep->chip->dev, u->buffer_size,
|
||||||
u->urb->transfer_buffer,
|
u->urb->transfer_buffer,
|
||||||
u->urb->transfer_dma);
|
u->urb->transfer_dma);
|
||||||
usb_free_urb(u->urb);
|
usb_free_urb(u->urb);
|
||||||
u->urb = NULL;
|
u->urb = NULL;
|
||||||
|
u->buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *usb_error_string(int err)
|
static const char *usb_error_string(int err)
|
||||||
|
|
Loading…
Reference in a new issue