Skip to contentSkip to conversation

media: i2c: ov772x: power off sensor on ID read errors

PATCH New Myeonghun Pak 1 participant 1 message Sep 13

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: ov772x: power off sensor on ID read errors

ov772x_video_probe() powers on the sensor before reading the product and manufacturer IDs. Since the register read error checks were added, any read failure returns directly and leaves the clock enabled and the powerdown GPIO asserted.

Route those failures through the existing power-off path. This covers the old OV7720 and OV7725 sensors while preserving the direct return when power-on itself fails, the product-ID mismatch path, and control setup behavior.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 30f3b17eaf49 ("media: ov772x: add checks for register read errors")
Assisted-by OpenAI:GPT-5.6
---
 drivers/media/i2c/ov772x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/ov772x.c +4 -4
index be3ba284ee..e20a109d60 100644
@@ -1280,10 +1280,10 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
 	/* Check and show product ID and manufacturer ID. */
 	ret = regmap_read(priv->regmap, PID, &pid);
 	if (ret < 0)
-		return ret;
+		goto done;
 	ret = regmap_read(priv->regmap, VER, &ver);
 	if (ret < 0)
-		return ret;
+		goto done;
 
 	switch (VERSION(pid, ver)) {
 	case OV7720:
@@ -1301,10 +1301,10 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
 
 	ret = regmap_read(priv->regmap, MIDH, &midh);
 	if (ret < 0)
-		return ret;
+		goto done;
 	ret = regmap_read(priv->regmap, MIDL, &midl);
 	if (ret < 0)
-		return ret;
+		goto done;
 
 	dev_info(&client->dev,
 		 "%s Product ID %0x:%0x Manufacturer ID %x:%x\n",
Signature · 1 line
2.47.1