Commit 57a89a85 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Wentao Guan
Browse files

media: uvcvideo: Fix double free in error path

stable inclusion
from stable-v6.6.76
commit 6c36dcd662ec5276782838660f8533a7cb26be49
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6c36dcd662ec5276782838660f8533a7cb26be49

--------------------------------

commit c6ef3a7fa97ec823a1e1af9085cf13db9f7b3bac upstream.

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: a31a4055 ("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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6c36dcd662ec5276782838660f8533a7cb26be49)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent a8ea870d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
	}