public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH 4.9 18/94] media: fsl-viu: fix error handling in viu_of_probe()
Date: Tue,  2 Oct 2018 06:24:32 -0700	[thread overview]
Message-ID: <20181002132501.739981466@linuxfoundation.org> (raw)
In-Reply-To: <20181002132500.494838053@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

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

From: Alexey Khoroshilov <khoroshilov@ispras.ru>

[ Upstream commit 662a99e145661c2b35155cf375044deae9b79896 ]

viu_of_probe() ignores fails in i2c_get_adapter(),
tries to unlock uninitialized mutex on error path.

The patch streamlining the error handling in viu_of_probe().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/media/platform/fsl-viu.c |   38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -1417,7 +1417,7 @@ static int viu_of_probe(struct platform_
 				     sizeof(struct viu_reg), DRV_NAME)) {
 		dev_err(&op->dev, "Error while requesting mem region\n");
 		ret = -EBUSY;
-		goto err;
+		goto err_irq;
 	}
 
 	/* remap registers */
@@ -1425,7 +1425,7 @@ static int viu_of_probe(struct platform_
 	if (!viu_regs) {
 		dev_err(&op->dev, "Can't map register set\n");
 		ret = -ENOMEM;
-		goto err;
+		goto err_irq;
 	}
 
 	/* Prepare our private structure */
@@ -1433,7 +1433,7 @@ static int viu_of_probe(struct platform_
 	if (!viu_dev) {
 		dev_err(&op->dev, "Can't allocate private structure\n");
 		ret = -ENOMEM;
-		goto err;
+		goto err_irq;
 	}
 
 	viu_dev->vr = viu_regs;
@@ -1449,16 +1449,21 @@ static int viu_of_probe(struct platform_
 	ret = v4l2_device_register(viu_dev->dev, &viu_dev->v4l2_dev);
 	if (ret < 0) {
 		dev_err(&op->dev, "v4l2_device_register() failed: %d\n", ret);
-		goto err;
+		goto err_irq;
 	}
 
 	ad = i2c_get_adapter(0);
+	if (!ad) {
+		ret = -EFAULT;
+		dev_err(&op->dev, "couldn't get i2c adapter\n");
+		goto err_v4l2;
+	}
 
 	v4l2_ctrl_handler_init(&viu_dev->hdl, 5);
 	if (viu_dev->hdl.error) {
 		ret = viu_dev->hdl.error;
 		dev_err(&op->dev, "couldn't register control\n");
-		goto err_vdev;
+		goto err_i2c;
 	}
 	/* This control handler will inherit the control(s) from the
 	   sub-device(s). */
@@ -1476,7 +1481,7 @@ static int viu_of_probe(struct platform_
 	vdev = video_device_alloc();
 	if (vdev == NULL) {
 		ret = -ENOMEM;
-		goto err_vdev;
+		goto err_hdl;
 	}
 
 	*vdev = viu_template;
@@ -1497,7 +1502,7 @@ static int viu_of_probe(struct platform_
 	ret = video_register_device(viu_dev->vdev, VFL_TYPE_GRABBER, -1);
 	if (ret < 0) {
 		video_device_release(viu_dev->vdev);
-		goto err_vdev;
+		goto err_unlock;
 	}
 
 	/* enable VIU clock */
@@ -1505,12 +1510,12 @@ static int viu_of_probe(struct platform_
 	if (IS_ERR(clk)) {
 		dev_err(&op->dev, "failed to lookup the clock!\n");
 		ret = PTR_ERR(clk);
-		goto err_clk;
+		goto err_vdev;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret) {
 		dev_err(&op->dev, "failed to enable the clock!\n");
-		goto err_clk;
+		goto err_vdev;
 	}
 	viu_dev->clk = clk;
 
@@ -1521,7 +1526,7 @@ static int viu_of_probe(struct platform_
 	if (request_irq(viu_dev->irq, viu_intr, 0, "viu", (void *)viu_dev)) {
 		dev_err(&op->dev, "Request VIU IRQ failed.\n");
 		ret = -ENODEV;
-		goto err_irq;
+		goto err_clk;
 	}
 
 	mutex_unlock(&viu_dev->lock);
@@ -1529,16 +1534,19 @@ static int viu_of_probe(struct platform_
 	dev_info(&op->dev, "Freescale VIU Video Capture Board\n");
 	return ret;
 
-err_irq:
-	clk_disable_unprepare(viu_dev->clk);
 err_clk:
-	video_unregister_device(viu_dev->vdev);
+	clk_disable_unprepare(viu_dev->clk);
 err_vdev:
-	v4l2_ctrl_handler_free(&viu_dev->hdl);
+	video_unregister_device(viu_dev->vdev);
+err_unlock:
 	mutex_unlock(&viu_dev->lock);
+err_hdl:
+	v4l2_ctrl_handler_free(&viu_dev->hdl);
+err_i2c:
 	i2c_put_adapter(ad);
+err_v4l2:
 	v4l2_device_unregister(&viu_dev->v4l2_dev);
-err:
+err_irq:
 	irq_dispose_mapping(viu_irq);
 	return ret;
 }



  parent reply	other threads:[~2018-10-02 13:36 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02 13:24 [PATCH 4.9 00/94] 4.9.131-stable review Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 01/94] crypto: skcipher - Fix -Wstringop-truncation warnings Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 02/94] tsl2550: fix lux1_input error in low light Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 03/94] vmci: type promotion bug in qp_host_get_user_memory() Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 04/94] x86/numa_emulation: Fix emulated-to-physical node mapping Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 05/94] staging: rts5208: fix missing error check on call to rtsx_write_register Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 06/94] uwb: hwa-rc: fix memory leak at probe Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 07/94] power: vexpress: fix corruption in notifier registration Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 08/94] iommu/amd: make sure TLB to be flushed before IOVA freed Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 09/94] Bluetooth: Add a new Realtek 8723DE ID 0bda:b009 Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 10/94] USB: serial: kobil_sct: fix modem-status error handling Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 11/94] 6lowpan: iphc: reset mac_header after decompress to fix panic Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 12/94] s390/mm: correct allocate_pgste proc_handler callback Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 13/94] power: remove possible deadlock when unregistering power_supply Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 14/94] md-cluster: clear another nodes suspend_area after the copy is finished Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 15/94] IB/core: type promotion bug in rdma_rw_init_one_mr() Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 16/94] media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt() Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 17/94] powerpc/kdump: Handle crashkernel memory reservation failure Greg Kroah-Hartman
2018-10-02 13:24 ` Greg Kroah-Hartman [this message]
2018-10-02 13:24 ` [PATCH 4.9 19/94] x86/tsc: Add missing header to tsc_msr.c Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 20/94] ARM: hwmod: RTC: Dont assume lock/unlock will be called with irq enabled Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 21/94] x86/entry/64: Add two more instruction suffixes Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 22/94] scsi: target/iscsi: Make iscsit_ta_authentication() respect the output buffer size Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 23/94] scsi: klist: Make it safe to use klists in atomic context Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 24/94] scsi: ibmvscsi: Improve strings handling Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 25/94] usb: wusbcore: security: cast sizeof to int for comparison Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 26/94] powerpc/powernv/ioda2: Reduce upper limit for DMA window size Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 27/94] alarmtimer: Prevent overflow for relative nanosleep Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 28/94] s390/extmem: fix gcc 8 stringop-overflow warning Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 29/94] ALSA: snd-aoa: add of_node_put() in error path Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 30/94] media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 31/94] media: soc_camera: ov772x: correct setting of banding filter Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 32/94] media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 33/94] staging: android: ashmem: Fix mmap size validation Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 34/94] drivers/tty: add error handling for pcmcia_loop_config Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 35/94] media: tm6000: add error handling for dvb_register_adapter Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 36/94] ALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 37/94] net: phy: xgmiitorgmii: Check read_status results Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 38/94] ath10k: protect ath10k_htt_rx_ring_free with rx_ring.lock Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 39/94] net: phy: xgmiitorgmii: Check phy_driver ready before accessing Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 40/94] drm/sun4i: Fix releasing node when enumerating enpoints Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 41/94] rndis_wlan: potential buffer overflow in rndis_wlan_auth_indication() Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 42/94] wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout() Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 43/94] ARM: mvebu: declare asm symbols as character arrays in pmsu.c Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 44/94] HID: hid-ntrig: add error handling for sysfs_create_group Greg Kroah-Hartman
2018-10-02 13:24 ` [PATCH 4.9 45/94] perf/x86/intel/lbr: Fix incomplete LBR call stack Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 46/94] scsi: bnx2i: add error handling for ioremap_nocache Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 47/94] scsi: megaraid_sas: Update controller info during resume Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 48/94] EDAC, i7core: Fix memleaks and use-after-free on probe and remove Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 49/94] ASoC: dapm: Fix potential DAI widget pointer deref when linking DAIs Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 50/94] module: exclude SHN_UNDEF symbols from kallsyms api Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 51/94] gpio: Fix wrong rounding in gpio-menz127 Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 52/94] nfsd: fix corrupted reply to badly ordered compound Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 53/94] EDAC: Fix memleak in module init error path Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 54/94] ARM: dts: dra7: fix DCAN node addresses Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 55/94] floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 56/94] tty: serial: lpuart: avoid leaking struct tty_struct Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 57/94] serial: cpm_uart: return immediately from console poll Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 58/94] spi: tegra20-slink: explicitly enable/disable clock Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 59/94] spi: sh-msiof: Fix invalid SPI use during system suspend Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 60/94] spi: sh-msiof: Fix handling of write value for SISTR register Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 61/94] spi: rspi: Fix invalid SPI use during system suspend Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 62/94] spi: rspi: Fix interrupted DMA transfers Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 63/94] regulator: fix crash caused by null driver data Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 64/94] USB: fix error handling in usb_driver_claim_interface() Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 65/94] USB: handle NULL config in usb_find_alt_setting() Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 66/94] slub: make ->cpu_partial unsigned int Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 67/94] media: uvcvideo: Support realteks UVC 1.5 device Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 68/94] USB: usbdevfs: sanitize flags more Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 69/94] USB: usbdevfs: restore warning for nonsensical flags Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 70/94] Revert "usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()" Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 71/94] USB: remove LPM management from usb_driver_claim_interface() Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 72/94] Input: elantech - enable middle button of touchpad on ThinkPad P72 Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 73/94] IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 74/94] IB/hfi1: Invalid user input can result in crash Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 75/94] IB/hfi1: Fix context recovery when PBC has an UnsupportedVL Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 76/94] scsi: target: iscsi: Use bin2hex instead of a re-implementation Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 77/94] serial: imx: restore handshaking irq for imx1 Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 78/94] IB/hfi1: Fix SL array bounds check Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 79/94] arm64: KVM: Tighten guest core register access from userspace Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 80/94] ext4: never move the system.data xattr out of the inode body Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 81/94] qed: Wait for ready indication before rereading the shmem Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 82/94] qed: Wait for MCP halt and resume commands to take place Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 83/94] thermal: of-thermal: disable passive polling when thermal zone is disabled Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 84/94] net: hns: fix length and page_offset overflow when CONFIG_ARM64_64K_PAGES Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 85/94] net: hns: fix skb->truesize underestimation Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 86/94] e1000: check on netif_running() before calling e1000_up() Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 87/94] e1000: ensure to free old tx/rx rings in set_ringparam() Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 88/94] hwmon: (ina2xx) fix sysfs shunt resistor read access Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 89/94] hwmon: (adt7475) Make adt7475_read_word() return errors Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 90/94] drm/amdgpu: Enable/disable gfx PG feature in rlc safe mode Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 91/94] drm/amdgpu: Update power state at the end of smu hw_init Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 92/94] arm/arm64: smccc-1.1: Make return values unsigned long Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 93/94] arm/arm64: smccc-1.1: Handle function result as parameters Greg Kroah-Hartman
2018-10-02 13:25 ` [PATCH 4.9 94/94] i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus Greg Kroah-Hartman
2018-10-02 19:19 ` [PATCH 4.9 00/94] 4.9.131-stable review Nathan Chancellor
2018-10-02 20:26 ` Shuah Khan
2018-10-03 12:54 ` Guenter Roeck
2018-10-03 19:50 ` Dan Rue

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=20181002132501.739981466@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexander.levin@microsoft.com \
    --cc=hans.verkuil@cisco.com \
    --cc=khoroshilov@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=stable@vger.kernel.org \
    /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