Commit 538314db authored by Cai Huoqing's avatar Cai Huoqing Committed by Mauro Carvalho Chehab

media: usb: stkwebcam: Update the reference count of the usb device structure

Use usb_get_dev() to increment the reference count of the usb device
structure in order to avoid releasing the structure while it is still in
use. And use usb_put_dev() to decrement the reference count and thus,
when it will be equal to 0 the structure will be released.
Signed-off-by: default avatarCai Huoqing <caihuoqing@baidu.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent aea54c13
...@@ -1234,6 +1234,11 @@ static void stk_v4l_dev_release(struct video_device *vd) ...@@ -1234,6 +1234,11 @@ static void stk_v4l_dev_release(struct video_device *vd)
if (dev->sio_bufs != NULL || dev->isobufs != NULL) if (dev->sio_bufs != NULL || dev->isobufs != NULL)
pr_err("We are leaking memory\n"); pr_err("We are leaking memory\n");
usb_put_intf(dev->interface); usb_put_intf(dev->interface);
usb_put_dev(dev->udev);
v4l2_ctrl_handler_free(&dev->hdl);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
} }
static const struct video_device stk_v4l_data = { static const struct video_device stk_v4l_data = {
...@@ -1309,7 +1314,7 @@ static int stk_camera_probe(struct usb_interface *interface, ...@@ -1309,7 +1314,7 @@ static int stk_camera_probe(struct usb_interface *interface,
init_waitqueue_head(&dev->wait_frame); init_waitqueue_head(&dev->wait_frame);
dev->first_init = 1; /* webcam LED management */ dev->first_init = 1; /* webcam LED management */
dev->udev = udev; dev->udev = usb_get_dev(udev);
dev->interface = interface; dev->interface = interface;
usb_get_intf(interface); usb_get_intf(interface);
...@@ -1365,6 +1370,7 @@ static int stk_camera_probe(struct usb_interface *interface, ...@@ -1365,6 +1370,7 @@ static int stk_camera_probe(struct usb_interface *interface,
error_put: error_put:
usb_put_intf(interface); usb_put_intf(interface);
usb_put_dev(dev->udev);
error: error:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
...@@ -1385,9 +1391,6 @@ static void stk_camera_disconnect(struct usb_interface *interface) ...@@ -1385,9 +1391,6 @@ static void stk_camera_disconnect(struct usb_interface *interface)
video_device_node_name(&dev->vdev)); video_device_node_name(&dev->vdev));
video_unregister_device(&dev->vdev); video_unregister_device(&dev->vdev);
v4l2_ctrl_handler_free(&dev->hdl);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment