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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <6c8c6746-34e2-4a97-9dff-622ed29071e9@kili.mountain>
Date: Mon, 10 Jun 2024 13:50:26 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Andrzej Hajda <andrzej.hajda@...el.com>,
	Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
Cc: Neil Armstrong <neil.armstrong@...aro.org>,
	Robert Foss <rfoss@...nel.org>,
	Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
	Jonas Karlman <jonas@...boo.se>,
	Jernej Skrabec <jernej.skrabec@...il.com>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>,
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: [PATCH v2] drm/bridge: it6505: remove unnecessary NULL checks

Smatch complains correctly that the NULL checking isn't consistent:

    drivers/gpu/drm/bridge/ite-it6505.c:2583 it6505_poweron()
    error: we previously assumed 'pdata->pwr18' could be null
    (see line 2569)

These the ->pwr18 pointer is allocated during probe using the
devm_regulator_get() function.  If CONFIG_REGULATOR is disabled then,
yes, it can return NULL but in that case regulator_enable() and
disable() functions are no-ops so passing a NULL pointer is okay.

Smatch is correct that the NULL checks are inconsistent but the
fix is to delete the unnecessary NULL checking.  Do the same for
"pdata->ovdd" as well.

Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
---
v2: In the first patch, I added a NULL check but that wasn't necessary
    or correct.

 drivers/gpu/drm/bridge/ite-it6505.c | 43 ++++++++++++-----------------
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 3f68c82888c2..d89d1bb9a8ec 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -2566,24 +2566,21 @@ static int it6505_poweron(struct it6505 *it6505)
 		return 0;
 	}
 
-	if (pdata->pwr18) {
-		err = regulator_enable(pdata->pwr18);
-		if (err) {
-			DRM_DEV_DEBUG_DRIVER(dev, "Failed to enable VDD18: %d",
-					     err);
-			return err;
-		}
+	err = regulator_enable(pdata->pwr18);
+	if (err) {
+		DRM_DEV_DEBUG_DRIVER(dev, "Failed to enable VDD18: %d",
+				     err);
+		return err;
 	}
 
-	if (pdata->ovdd) {
-		/* time interval between IVDD and OVDD at least be 1ms */
-		usleep_range(1000, 2000);
-		err = regulator_enable(pdata->ovdd);
-		if (err) {
-			regulator_disable(pdata->pwr18);
-			return err;
-		}
+	/* time interval between IVDD and OVDD at least be 1ms */
+	usleep_range(1000, 2000);
+	err = regulator_enable(pdata->ovdd);
+	if (err) {
+		regulator_disable(pdata->pwr18);
+		return err;
 	}
+
 	/* time interval between OVDD and SYSRSTN at least be 10ms */
 	if (pdata->gpiod_reset) {
 		usleep_range(10000, 20000);
@@ -2618,17 +2615,13 @@ static int it6505_poweroff(struct it6505 *it6505)
 	if (pdata->gpiod_reset)
 		gpiod_set_value_cansleep(pdata->gpiod_reset, 0);
 
-	if (pdata->pwr18) {
-		err = regulator_disable(pdata->pwr18);
-		if (err)
-			return err;
-	}
+	err = regulator_disable(pdata->pwr18);
+	if (err)
+		return err;
 
-	if (pdata->ovdd) {
-		err = regulator_disable(pdata->ovdd);
-		if (err)
-			return err;
-	}
+	err = regulator_disable(pdata->ovdd);
+	if (err)
+		return err;
 
 	it6505->powered = false;
 	it6505->sink_count = 0;
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ