media: gspca: Add error handling for stv06xx_read_sensor()

commit 398a1b33f1479af35ca915c5efc9b00d6204f8fa upstream.

In hdcs_init(), the return value of stv06xx_read_sensor() needs to be
checked. A proper implementation can be found in vv6410_dump(). Add a
check in loop condition and propergate error code to fix this issue.

Fixes: 4c98834add ("V4L/DVB (10048): gspca - stv06xx: New subdriver.")
Cc: stable@vger.kernel.org # v2.6+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wentao Liang
2025-04-22 11:07:39 +08:00
committed by Greg Kroah-Hartman
parent ec5c328606
commit 025a943c49

View File

@@ -520,12 +520,13 @@ static int hdcs_init(struct sd *sd)
static int hdcs_dump(struct sd *sd) static int hdcs_dump(struct sd *sd)
{ {
u16 reg, val; u16 reg, val;
int err = 0;
pr_info("Dumping sensor registers:\n"); pr_info("Dumping sensor registers:\n");
for (reg = HDCS_IDENT; reg <= HDCS_ROWEXPH; reg++) { for (reg = HDCS_IDENT; reg <= HDCS_ROWEXPH && !err; reg++) {
stv06xx_read_sensor(sd, reg, &val); err = stv06xx_read_sensor(sd, reg, &val);
pr_info("reg 0x%02x = 0x%02x\n", reg, val); pr_info("reg 0x%02x = 0x%02x\n", reg, val);
} }
return 0; return (err < 0) ? err : 0;
} }