]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
media: stk-webcam: Fix use after free on disconnect
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 22 Sep 2017 13:48:41 +0000 (09:48 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Dec 2017 15:06:46 +0000 (10:06 -0500)
We free the stk_camera device too early.  It's allocate first in probe
and it should be freed last in stk_camera_disconnect().

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/usb/stkwebcam/stk-webcam.c

index c0bba773db25b0032bfb3f422117c6d08de5e382..e748c976d967552ce17d56f68e17378b1e5c4a92 100644 (file)
@@ -1241,7 +1241,6 @@ static void stk_v4l_dev_release(struct video_device *vd)
        if (dev->sio_bufs != NULL || dev->isobufs != NULL)
                pr_err("We are leaking memory\n");
        usb_put_intf(dev->interface);
-       kfree(dev);
 }
 
 static const struct video_device stk_v4l_data = {
@@ -1391,6 +1390,7 @@ static void stk_camera_disconnect(struct usb_interface *interface)
        video_unregister_device(&dev->vdev);
        v4l2_ctrl_handler_free(&dev->hdl);
        v4l2_device_unregister(&dev->v4l2_dev);
+       kfree(dev);
 }
 
 #ifdef CONFIG_PM