summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.com>2018-01-08 09:21:07 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-08 14:26:31 +0200
commit1f17d5033fe3c435556d8fb731f3a51ca073ce85 (patch)
tree7a7d198d8211debacd2441c6601e83d25391d91e
parent5f834dd24baec1f9926e8a06609e0906fd607b06 (diff)
downloadlinux-stable-1f17d5033fe3c435556d8fb731f3a51ca073ce85.tar.gz
linux-stable-1f17d5033fe3c435556d8fb731f3a51ca073ce85.tar.bz2
linux-stable-1f17d5033fe3c435556d8fb731f3a51ca073ce85.zip
media: usbtv: prevent double free in error case
commit 50e7044535537b2a54c7ab798cd34c7f6d900bd2 upstream. Quoting the original report: It looks like there is a double-free vulnerability in Linux usbtv driver on an error path of usbtv_probe function. When audio registration fails, usbtv_video_free function ends up freeing usbtv data structure, which gets freed the second time under usbtv_video_fail label. usbtv_audio_fail: usbtv_video_free(usbtv); => v4l2_device_put(&usbtv->v4l2_dev); => v4l2_device_put => kref_put => v4l2_device_release => usbtv_release (CALLBACK) => kfree(usbtv) (1st time) usbtv_video_fail: usb_set_intfdata(intf, NULL); usb_put_dev(usbtv->udev); kfree(usbtv); (2nd time) So, as we have refcounting, use it Reported-by: Yavuz, Tuba <tuba@ece.ufl.edu> Signed-off-by: Oliver Neukum <oneukum@suse.com> CC: stable@vger.kernel.org Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/media/usb/usbtv/usbtv-core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index 71fb5734995b..68df16b3ce72 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -112,6 +112,8 @@ static int usbtv_probe(struct usb_interface *intf,
return 0;
usbtv_audio_fail:
+ /* we must not free at this point */
+ usb_get_dev(usbtv->udev);
usbtv_video_free(usbtv);
usbtv_video_fail: