From cdd2238a5e0ec061fb5001d71fdb6086c0fad5a1 Mon Sep 17 00:00:00 2001 From: Leslin <2238468186@qq.com> Date: Mon, 13 May 2024 10:17:17 +0800 Subject: [PATCH] media:usb:msi2500: Fix a possible null-pointer derefer in msi2500_stop_streaming() driver inclusion category: bugfix bugzilla: gitee.com/openeuler/kernel/issues/I9L3MH ------------------------------------------------- original changelog In msi2500_stop_streaming(), there is an if statement on line 882 to check whether dev->udev is NULL: if (dev->udev) When dev->udev is NULL, it is used on line 891: msi2500_ctrl_msg(dev, CMD_STOP_STREAMING, 0) usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), ...) Thus, a possible null-pointer dereference may occur. To fix this bug, dev->udev is checked before calling msi2500_ctrl_msg(). Fixes: 6c4027e29863 ("MEDIA: USB: check dev->udev before calling msi2500_ctrl_msg()") Signed-off-by: Leslin <2238468186@qq.com> --- drivers/media/usb/msi2500/msi2500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c index 65ef755adfdc1..b7be2338f7444 100644 --- a/drivers/media/usb/msi2500/msi2500.c +++ b/drivers/media/usb/msi2500/msi2500.c @@ -886,7 +886,7 @@ static void msi2500_stop_streaming(struct vb2_queue *vq) /* according to tests, at least 700us delay is required */ msleep(20); - if (!msi2500_ctrl_msg(dev, CMD_STOP_STREAMING, 0)) { + if (dev->udev && !msi2500_ctrl_msg(dev, CMD_STOP_STREAMING, 0)) { /* sleep USB IF / ADC */ msi2500_ctrl_msg(dev, CMD_WREG, 0x01000003); } -- Gitee