mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: mt9t112: fix missing IS_ERR() check before PTR_ERR()
@ 2026-07-20 10:59 Uday Khare
  2026-07-20 11:34 ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Uday Khare @ 2026-07-20 10:59 UTC (permalink / raw)
  To: sakari.ailus, jacopo, mchehab; +Cc: linux-media, linux-kernel, Uday Khare

In mt9t112_probe(), the -ENOENT check after devm_v4l2_sensor_clk_get() is
missing an IS_ERR() guard.

Without IS_ERR(), PTR_ERR(priv->clk) is executed unconditionally,
including on successful clock lookups where priv->clk points to a valid
struct clk pointer.  Calling PTR_ERR() on a valid pointer reinterprets its
address as a signed long integer; the result is arbitrary and leads to an
invalid comparison against -ENOENT.

Fix this by nesting the -ENOENT check inside an IS_ERR() guard block.

Fixes: 6a26f141bf62 ("media: i2c: mt9t112: Remove soc_camera dependencies")
Signed-off-by: Uday Khare <udaykhare77@gmail.com>
---
 drivers/media/i2c/mt9t112.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/mt9t112.c b/drivers/media/i2c/mt9t112.c
index a8e2a3cf3456..56b7c8910112 100644
--- a/drivers/media/i2c/mt9t112.c
+++ b/drivers/media/i2c/mt9t112.c
@@ -1079,10 +1079,12 @@ static int mt9t112_probe(struct i2c_client *client)
 	v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
 
 	priv->clk = devm_v4l2_sensor_clk_get(&client->dev, "extclk");
-	if (PTR_ERR(priv->clk) == -ENOENT)
-		priv->clk = NULL;
-	else if (IS_ERR(priv->clk))
-		return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
-				     "Unable to get clock \"extclk\"\n");
+	if (IS_ERR(priv->clk)) {
+		if (PTR_ERR(priv->clk) == -ENOENT)
+			priv->clk = NULL;
+		else
+			return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
+					     "Unable to get clock \"extclk\"\n");
+	}
 
 	priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
-- 
2.55.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-20 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-20 10:59 [PATCH] media: i2c: mt9t112: fix missing IS_ERR() check before PTR_ERR() Uday Khare
2026-07-20 11:34 ` Sakari Ailus
2026-07-20 11:48   ` [PATCH v2] media: i2c: mt9t112: fix incorrect PTR_ERR() call on non-error pointer Uday Khare

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®