media: i2c: imx296: fix error checking in imx296_read_temperature()
authorDan Carpenter <error27@gmail.com>
Wed, 22 Feb 2023 13:59:51 +0000 (16:59 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 25 May 2023 14:21:21 +0000 (16:21 +0200)
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")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/imx296.c

index 70c129833601e3e57f5d46cbe4d2bae74729f1bd..c0b9a5349668d032b8202b0c9a874d9c77c002ae 100644 (file)
@@ -922,10 +922,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;