summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.com>2019-05-09 04:57:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-04 09:29:37 +0200
commit7951663c80a558ac97978e19ba893f9f6d3dec3d (patch)
treec7c17842dd5dbb2796c5ab65c82ae8c16078460b /drivers/media/usb
parentb2769f0086dc462a86f5e46f6c56add9c8e06b35 (diff)
downloadlinux-stable-7951663c80a558ac97978e19ba893f9f6d3dec3d.tar.gz
linux-stable-7951663c80a558ac97978e19ba893f9f6d3dec3d.tar.bz2
linux-stable-7951663c80a558ac97978e19ba893f9f6d3dec3d.zip
media: cpia2_usb: first wake up, then free in disconnect
commit eff73de2b1600ad8230692f00bc0ab49b166512a upstream. Kasan reported a use after free in cpia2_usb_disconnect() It first freed everything and then woke up those waiting. The reverse order is correct. Fixes: 6c493f8b28c67 ("[media] cpia2: major overhaul to get it in a working state again") Signed-off-by: Oliver Neukum <oneukum@suse.com> Reported-by: syzbot+0c90fc937c84f97d0aa6@syzkaller.appspotmail.com Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index b2268981c963..17468f7d78ed 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -893,7 +893,6 @@ static void cpia2_usb_disconnect(struct usb_interface *intf)
cpia2_unregister_camera(cam);
v4l2_device_disconnect(&cam->v4l2_dev);
mutex_unlock(&cam->v4l2_lock);
- v4l2_device_put(&cam->v4l2_dev);
if(cam->buffers) {
DBG("Wakeup waiting processes\n");
@@ -902,6 +901,8 @@ static void cpia2_usb_disconnect(struct usb_interface *intf)
wake_up_interruptible(&cam->wq_stream);
}
+ v4l2_device_put(&cam->v4l2_dev);
+
LOG("CPiA2 camera disconnected.\n");
}