summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-09-30 12:01:29 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-26 13:15:36 +0200
commit848f473a1e9d98a79bc83e9979ee5c6ba8e436bc (patch)
tree6fe016cef6aaba1e7282daa3f392c179d816a092
parent0604e5e5537af099ea2f6dfd892afe5c92db8a80 (diff)
downloadlinux-stable-848f473a1e9d98a79bc83e9979ee5c6ba8e436bc.tar.gz
linux-stable-848f473a1e9d98a79bc83e9979ee5c6ba8e436bc.tar.bz2
linux-stable-848f473a1e9d98a79bc83e9979ee5c6ba8e436bc.zip
ALSA: usb-audio: Fix NULL dererence at error path
commit 568be8aaf8a535f79c4db76cabe17b035aa2584d 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>
-rw-r--r--sound/usb/endpoint.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a00df37451b6..f81e74daacb7 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -86,12 +86,13 @@ static inline unsigned get_usb_high_speed_rate(unsigned int rate)
*/
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,
u->urb->transfer_buffer,
u->urb->transfer_dma);
usb_free_urb(u->urb);
u->urb = NULL;
+ u->buffer_size = 0;
}
static const char *usb_error_string(int err)