Message ID | Y/Yf19AE78jn5YW7@kili (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: i2c: imx296: fix error checking in imx296_read_temperature() | expand |
Hi Dan, Thank you for the patch. On Wed, Feb 22, 2023 at 04:59:51PM +0300, Dan Carpenter wrote: > 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> > --- > drivers/media/i2c/imx296.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/imx296.c b/drivers/media/i2c/imx296.c > index 3c12b6edeac9..bb0c896f3d67 100644 > --- a/drivers/media/i2c/imx296.c > +++ b/drivers/media/i2c/imx296.c > @@ -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; >
diff --git a/drivers/media/i2c/imx296.c b/drivers/media/i2c/imx296.c index 3c12b6edeac9..bb0c896f3d67 100644 --- a/drivers/media/i2c/imx296.c +++ b/drivers/media/i2c/imx296.c @@ -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;
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> --- drivers/media/i2c/imx296.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)