Skip to contentSkip to conversation

media: i2c: imx296: fix error checking in imx296_read_temperature()

PATCH In review Dan Carpenter 2 participants 2 messages Feb 23, 2023

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

PATCH 1/1 media: i2c: imx296: fix error checking in imx296_read_temperature()

The "& IMX296_TMDOUT_MASK" means that "tmdout" can't be negative so the error checking will not work.

Fixes cb33db2b6ccf ("media: i2c: IMX296 camera sensor driver")
---
 drivers/media/i2c/imx296.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/imx296.c +3 -1
index 3c12b6edeac9..bb0c896f3d67 100644
@@ -931,10 +931,12 @@ static int imx296_read_temperature(struct imx296 *sensor, int *temp)
 	if (ret < 0)
 		return ret;
 
-	tmdout = imx296_read(sensor, IMX296_TMDOUT) & IMX296_TMDOUT_MASK;
+	tmdout = imx296_read(sensor, IMX296_TMDOUT);
 	if (tmdout < 0)
 		return tmdout;
 
+	tmdout &= IMX296_TMDOUT_MASK;
+
 	/* T(°C) = 246.312 - 0.304 * TMDOUT */;
 	*temp = 246312 - 304 * tmdout;
 
Signature · 1 line
2.39.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,

Thank you for the patch.

Quoted 5 lines · Dan Carpenter

The "& IMX296_TMDOUT_MASK" means that "tmdout" can't be negative so the error checking will not work.

Fixes cb33db2b6ccf ("media: i2c: IMX296 camera sensor driver")
Quoted 22 lines
---
 drivers/media/i2c/imx296.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/imx296.c +3 -1
index 3c12b6edeac9..bb0c896f3d67 100644
@@ -931,10 +931,12 @@ static int imx296_read_temperature(struct imx296 *sensor, int *temp)
 	if (ret < 0)
 		return ret;
 
-	tmdout = imx296_read(sensor, IMX296_TMDOUT) & IMX296_TMDOUT_MASK;
+	tmdout = imx296_read(sensor, IMX296_TMDOUT);
 	if (tmdout < 0)
 		return tmdout;
 
+	tmdout &= IMX296_TMDOUT_MASK;
+
 	/* T(°C) = 246.312 - 0.304 * TMDOUT */;
 	*temp = 246312 - 304 * tmdout;
 
Signature · 3 lines
Regards,

Laurent Pinchart