]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
media: uvcvideo: Fix double free in error path
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 7 Nov 2024 23:51:30 +0000 (01:51 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 19 Dec 2024 14:44:43 +0000 (14:44 +0000)
If the uvc_status_init() function fails to allocate the int_urb, it will
free the dev->status pointer but doesn't reset the pointer to NULL. This
results in the kfree() call in uvc_status_cleanup() trying to
double-free the memory. Fix it by resetting the dev->status pointer to
NULL after freeing it.

Fixes: a31a4055473b ("V4L/DVB:usbvideo:don't use part of buffer for USB transfer #4")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20241107235130.31372-1-laurent.pinchart@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/usb/uvc/uvc_status.c

index 02c90acf696472210f7f511b75d229e8840a6780..d269d163b579afa9f55a9488ab836c86a3507c52 100644 (file)
@@ -269,6 +269,7 @@ int uvc_status_init(struct uvc_device *dev)
        dev->int_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!dev->int_urb) {
                kfree(dev->status);
+               dev->status = NULL;
                return -ENOMEM;
        }