mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Pavel Skripkin <paskripkin@gmail.com>,
	syzbot+efe9aefc31ae1e6f7675@syzkaller.appspotmail.com,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-usb@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 5.11 026/115] media: drivers/media/usb: fix memory leak in zr364xx_probe
Date: Mon,  3 May 2021 12:35:30 -0400	[thread overview]
Message-ID: <20210503163700.2852194-26-sashal@kernel.org> (raw)
In-Reply-To: <20210503163700.2852194-1-sashal@kernel.org>

From: Pavel Skripkin <paskripkin@gmail.com>

[ Upstream commit 9c39be40c0155c43343f53e3a439290c0fec5542 ]

syzbot reported memory leak in zr364xx_probe()[1].
The problem was in invalid error handling order.
All error conditions rigth after v4l2_ctrl_handler_init()
must call v4l2_ctrl_handler_free().

Reported-by: syzbot+efe9aefc31ae1e6f7675@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/usb/zr364xx/zr364xx.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index d29b861367ea..1ef611e08323 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1430,7 +1430,7 @@ static int zr364xx_probe(struct usb_interface *intf,
 	if (hdl->error) {
 		err = hdl->error;
 		dev_err(&udev->dev, "couldn't register control\n");
-		goto unregister;
+		goto free_hdlr_and_unreg_dev;
 	}
 	/* save the init method used by this camera */
 	cam->method = id->driver_info;
@@ -1503,7 +1503,7 @@ static int zr364xx_probe(struct usb_interface *intf,
 	if (!cam->read_endpoint) {
 		err = -ENOMEM;
 		dev_err(&intf->dev, "Could not find bulk-in endpoint\n");
-		goto unregister;
+		goto free_hdlr_and_unreg_dev;
 	}
 
 	/* v4l */
@@ -1515,7 +1515,7 @@ static int zr364xx_probe(struct usb_interface *intf,
 	/* load zr364xx board specific */
 	err = zr364xx_board_init(cam);
 	if (err)
-		goto unregister;
+		goto free_hdlr_and_unreg_dev;
 	err = v4l2_ctrl_handler_setup(hdl);
 	if (err)
 		goto board_uninit;
@@ -1533,7 +1533,7 @@ static int zr364xx_probe(struct usb_interface *intf,
 	err = video_register_device(&cam->vdev, VFL_TYPE_VIDEO, -1);
 	if (err) {
 		dev_err(&udev->dev, "video_register_device failed\n");
-		goto free_handler;
+		goto board_uninit;
 	}
 	cam->v4l2_dev.release = zr364xx_release;
 
@@ -1541,11 +1541,10 @@ static int zr364xx_probe(struct usb_interface *intf,
 		 video_device_node_name(&cam->vdev));
 	return 0;
 
-free_handler:
-	v4l2_ctrl_handler_free(hdl);
 board_uninit:
 	zr364xx_board_uninit(cam);
-unregister:
+free_hdlr_and_unreg_dev:
+	v4l2_ctrl_handler_free(hdl);
 	v4l2_device_unregister(&cam->v4l2_dev);
 free_cam:
 	kfree(cam);
-- 
2.30.2


  parent reply	other threads:[~2021-05-03 16:42 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03 16:35 [PATCH AUTOSEL 5.11 001/115] drm: Added orientation quirk for OneGX1 Pro Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 002/115] drm/qxl: do not run release if qxl failed to init Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 003/115] drm/qxl: release shadow on shutdown Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 004/115] drm/ast: Fix invalid usage of AST_MAX_HWC_WIDTH in cursor atomic_check Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 005/115] drm/amd/display: changing sr exit latency Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 006/115] drm/amd/display: Fix MPC OGAM power on/off sequence Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 007/115] drm/ast: fix memory leak when unload the driver Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 008/115] drm/amd/display: Check for DSC support instead of ASIC revision Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 009/115] drm/amd/display: Don't optimize bandwidth before disabling planes Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 010/115] drm/amd/display: Return invalid state if GPINT times out Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 011/115] drm/amdgpu/display: buffer INTERRUPT_LOW_IRQ_CONTEXT interrupt work Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 012/115] drm/amd/display/dc/dce/dce_aux: Remove duplicate line causing 'field overwritten' issue Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 013/115] scsi: lpfc: Fix incorrect dbde assignment when building target abts wqe Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 014/115] scsi: lpfc: Fix pt2pt connection does not recover after LOGO Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 015/115] scsi: lpfc: Fix status returned in lpfc_els_retry() error exit path Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 016/115] scsi: lpfc: Fix PLOGI ACC to be transmit after REG_LOGIN Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 017/115] scsi: lpfc: Fix ADISC handling that never frees nodes Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 018/115] drm/amdgpu: Fix some unload driver issues Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 019/115] sched/pelt: Fix task util_est update filtering Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 020/115] sched/topology: fix the issue groups don't span domain->span for NUMA diameter > 2 Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 021/115] kvfree_rcu: Use same set of GFP flags as does single-argument Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 022/115] drm/virtio: fix possible leak/unlock virtio_gpu_object_array Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 023/115] scsi: target: pscsi: Fix warning in pscsi_complete_cmd() Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 024/115] media: ite-cir: check for receive overflow Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 025/115] media: drivers: media: pci: sta2x11: fix Kconfig dependency on GPIOLIB Sasha Levin
2021-05-03 16:35 ` Sasha Levin [this message]
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 027/115] media: cx23885: add more quirks for reset DMA on some AMD IOMMU Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 028/115] media: imx: capture: Return -EPIPE from __capture_legacy_try_fmt() Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 029/115] atomisp: don't let it go past pipes array Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 030/115] power: supply: bq27xxx: fix power_avg for newer ICs Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 031/115] extcon: arizona: Fix some issues when HPDET IRQ fires after the jack has been unplugged Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 032/115] extcon: arizona: Fix various races on driver unbind Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 033/115] media: media/saa7164: fix saa7164_encoder_register() memory leak bugs Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 034/115] media: gspca/sq905.c: fix uninitialized variable Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 035/115] media: v4l2-ctrls.c: initialize flags field of p_fwht_params Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 036/115] media: pci: saa7164: Rudimentary spelling fixes in the file saa7164-types.h Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 037/115] power: supply: Use IRQF_ONESHOT Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 038/115] backlight: qcom-wled: Use sink_addr for sync toggle Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 039/115] backlight: qcom-wled: Fix FSC update issue for WLED5 Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 040/115] drm/bridge/analogix/anx78xx: Setup encoder before registering connector Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 041/115] drm/bridge/analogix/anx78xx: Cleanup on error in anx78xx_bridge_attach() Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 042/115] drm/amdgpu: mask the xgmi number of hops reported from psp to kfd Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 043/115] drm/amdkfd: Fix UBSAN shift-out-of-bounds warning Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 044/115] drm/amdgpu : Fix asic reset regression issue introduce by 8f211fe8ac7c4f Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 045/115] drm/amd/pm: fix workload mismatch on vega10 Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 046/115] drm/amd/display: Fix UBSAN warning for not a valid value for type '_Bool' Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 047/115] drm/amd/display: DCHUB underflow counter increasing in some scenarios Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 048/115] drm/amd/display: fix dml prefetch validation Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 049/115] drm/amdgpu: Fix memory leak Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 050/115] scsi: qla2xxx: Always check the return value of qla24xx_get_isp_stats() Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 051/115] drm/vkms: fix misuse of WARN_ON Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 052/115] scsi: qla2xxx: Fix use after free in bsg Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 053/115] mmc: sdhci-esdhc-imx: validate pinctrl before use it Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 054/115] mmc: sdhci-pci: Add PCI IDs for Intel LKF Sasha Levin
2021-05-03 16:35 ` [PATCH AUTOSEL 5.11 055/115] mmc: sdhci-brcmstb: Remove CQE quirk Sasha Levin
2021-05-03 16:36 ` [PATCH AUTOSEL 5.11 056/115] ata: ahci: Disable SXS for Hisilicon Kunpeng920 Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210503163700.2852194-26-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+efe9aefc31ae1e6f7675@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®