Re: OOPS on USB sound card disconnect while in use

Takashi Iwai <[email protected]> Thu, 25 Sep 2008 12:46:27 +0200
Newsgroups gmane.linux.alsa.devel,gmane.linux.usb.devel
Message-ID <s5hvdwksdto.wl%[email protected]>
At Mon, 22 Sep 2008 01:00:30 +0300,
Lasse K=E4rkk=E4inen wrote:
> =

> This has been broken for a long time.
> =

> Symtoms: programs using the card while it is disconnected get stuck and =

> cannot be killed, and OOPS is printed on the log:

Does the patch below cure the problem?


thanks,

Takashi

diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index c0c7770..5962e4b 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1112,6 +1112,15 @@ void snd_usbmidi_disconnect(struct list_head* p)
 		}
 		if (ep->in)
 			usb_kill_urb(ep->in->urb);
+		/* free endpoints here; later call can result in Oops */
+		if (ep->out) {
+			snd_usbmidi_out_endpoint_delete(ep->out);
+			ep->out =3D NULL;
+		}
+		if (ep->in) {
+			snd_usbmidi_in_endpoint_delete(ep->in);
+			ep->in =3D NULL;
+		}
 	}
 	del_timer_sync(&umidi->error_timer);
 }