Skip to contentSkip to conversation

ALSA:usb-audio:check urb before kill it

PATCH In review Defang Bo 3 participants 3 messages Dec 27, 2020 – Dec 29, 2020 Sound

lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 1/1 ALSA:usb-audio:check urb before kill it

Similar to commit<124751d5e>, there should be a check for urb before kill it.

---
 sound/usb/mixer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/usb/mixer.c +4 -2
index 81e987e..0223ef3 100644
@@ -3589,8 +3589,10 @@ void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer)
 /* stop any bus activity of a mixer */
 static void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer)
 {
-	usb_kill_urb(mixer->urb);
-	usb_kill_urb(mixer->rc_urb);
+	if (mixer->urb)
+		usb_kill_urb(mixer->urb);
+	if (mixer->rc_urb)
+		usb_kill_urb(mixer->rc_urb);
 }
 
 static int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
Signature · 1 line
2.7.4
#2 lore raw
In reply to Defang Bo
Quoted 4 lines · Defang Bo

Similar to commit<124751d5e>, there should be a check for urb before kill it.

usb_kill_urb() accepts the NULL urb pointer, so the NULL check in the caller side is basically superfluous.

thanks,

Takashi

Quoted 24 lines
---
 sound/usb/mixer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/usb/mixer.c +4 -2
index 81e987e..0223ef3 100644
@@ -3589,8 +3589,10 @@ void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer)
 /* stop any bus activity of a mixer */
 static void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer)
 {
-	usb_kill_urb(mixer->urb);
-	usb_kill_urb(mixer->rc_urb);
+	if (mixer->urb)
+		usb_kill_urb(mixer->urb);
+	if (mixer->rc_urb)
+		usb_kill_urb(mixer->rc_urb);
 }
 
 static int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
Signature · 1 line
2.7.4