lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250113101749.2440878-1-mordan@ispras.ru>
Date: Mon, 13 Jan 2025 13:17:49 +0300
From: Vitalii Mordan <mordan@...ras.ru>
To: Maxime Ripard <mripard@...nel.org>
Cc: Vitalii Mordan <mordan@...ras.ru>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Niklas Söderlund <niklas.soderlund+renesas@...natech.se>,
	Benoit Parrot <bparrot@...com>,
	Sakari Ailus <sakari.ailus@...ux.intel.com>,
	linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Fedor Pchelkin <pchelkin@...ras.ru>,
	Alexey Khoroshilov <khoroshilov@...ras.ru>,
	Vadim Mutilin <mutilin@...ras.ru>,
	stable@...r.kernel.org
Subject: [PATCH] media: cdns-csi2rx: fix call balance for csi2rx->p_clk handling routines

If the clock csi2rx->p_clk was not enabled in csi2rx_stop(), it should not
be disabled in any path.

Conversely, if it was enabled in csi2rx_stop(), it must be disabled in all
error paths to ensure proper cleanup.

Found by Linux Verification Center (linuxtesting.org) with Klever.

Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")
Cc: stable@...r.kernel.org
Signed-off-by: Vitalii Mordan <mordan@...ras.ru>
---
 drivers/media/platform/cadence/cdns-csi2rx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 4d64df829e75..e7e8decf9a02 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -322,11 +322,14 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 
 static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 {
+	int ret, ret_clk;
 	unsigned int i;
 	u32 val;
-	int ret;
 
-	clk_prepare_enable(csi2rx->p_clk);
+	ret_clk = clk_prepare_enable(csi2rx->p_clk);
+	if (ret_clk)
+		dev_warn(csi2rx->dev,
+			 "Couldn't prepare and enable P clock\n");
 	reset_control_assert(csi2rx->sys_rst);
 	clk_disable_unprepare(csi2rx->sys_clk);
 
@@ -348,7 +351,8 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
 	}
 
 	reset_control_assert(csi2rx->p_rst);
-	clk_disable_unprepare(csi2rx->p_clk);
+	if (!ret_clk)
+		clk_disable_unprepare(csi2rx->p_clk);
 
 	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
 		dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ