From: David Ellingsworth Date: Tue, 14 Oct 2008 01:31:15 +0000 (-0300) Subject: V4L/DVB (9194): stk-webcam: fix crash on close after disconnect X-Git-Tag: v2.6.28-rc1~256^2~91 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f051ae1866e67567b4f33371969dee9cdddb34ed;p=linux-2.6-omap-h63xx.git V4L/DVB (9194): stk-webcam: fix crash on close after disconnect This patch prevents stk-webcam from updating usb device information once the camera has been removed. This prevents a crash that would otherwise occur if the camera is disconnected while it is still in use. Signed-off-by: David Ellingsworth Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index f1d5b3eaa19..edaea496451 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c @@ -559,7 +559,7 @@ static void stk_clean_iso(struct stk_camera *dev) urb = dev->isobufs[i].urb; if (urb) { - if (atomic_read(&dev->urbs_used)) + if (atomic_read(&dev->urbs_used) && is_present(dev)) usb_kill_urb(urb); usb_free_urb(urb); } @@ -688,18 +688,14 @@ static int v4l_stk_release(struct inode *inode, struct file *fp) { struct stk_camera *dev = fp->private_data; - if (dev->owner != fp) { - usb_autopm_put_interface(dev->interface); - return 0; + if (dev->owner == fp) { + stk_stop_stream(dev); + stk_free_buffers(dev); + dev->owner = NULL; } - stk_stop_stream(dev); - - stk_free_buffers(dev); - - dev->owner = NULL; - - usb_autopm_put_interface(dev->interface); + if(is_present(dev)) + usb_autopm_put_interface(dev->interface); return 0; }