diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2009-02-04 19:33:21 +0100 |
---|---|---|
committer | Jean-Francois Moine <moinejf@free.fr> | 2009-02-04 19:33:21 +0100 |
commit | e086109f0cad2b76f5a32cf18db838e2026712bb (patch) | |
tree | 2b45fb7d040e4e4c179ae9fc9af323aa414188de | |
parent | c1d676109e87244212120f7ba938d67c3d0571a0 (diff) | |
download | mediapointer-dvb-s2-e086109f0cad2b76f5a32cf18db838e2026712bb.tar.gz mediapointer-dvb-s2-e086109f0cad2b76f5a32cf18db838e2026712bb.tar.bz2 |
gspca - main: Destroy the URBs at disconnection time.
From: Adam Baker <linux@baker-net.org.uk>
If a device using the gspca framework is unplugged while it is still streaming
then the call that is used to free the URBs that have been allocated occurs
after the pointer it uses becomes invalid at the end of gspca_disconnect.
Make another cleanup call in gspca_disconnect while the pointer is still
valid (multiple calls are OK as destroy_urbs checks for pointers already
being NULL.
Priority: high
Signed-off-by: Adam Baker <linux@baker-net.org.uk>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
-rw-r--r-- | linux/drivers/media/video/gspca/gspca.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/linux/drivers/media/video/gspca/gspca.c b/linux/drivers/media/video/gspca/gspca.c index cac937040..64842682e 100644 --- a/linux/drivers/media/video/gspca/gspca.c +++ b/linux/drivers/media/video/gspca/gspca.c @@ -434,6 +434,7 @@ static void destroy_urbs(struct gspca_dev *gspca_dev) if (urb == NULL) break; + BUG_ON(!gspca_dev->dev); gspca_dev->urb[i] = NULL; if (!gspca_dev->present) usb_kill_urb(urb); @@ -1953,8 +1954,12 @@ void gspca_disconnect(struct usb_interface *intf) { struct gspca_dev *gspca_dev = usb_get_intfdata(intf); + mutex_lock(&gspca_dev->usb_lock); gspca_dev->present = 0; + mutex_unlock(&gspca_dev->usb_lock); + destroy_urbs(gspca_dev); + gspca_dev->dev = NULL; usb_set_intfdata(intf, NULL); /* release the device */ |