Skip to content

Commit

Permalink
media: gspca: properly check for errors in po1030_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit dacb408 ]

If m5602_write_sensor() or m5602_write_bridge() fail, do not continue to
initialize the device but return the error to the calling funtion.

Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Link: https://lore.kernel.org/r/20210503115736.2104747-64-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
gregkh committed Jun 3, 2021
1 parent 3d8ac40 commit 32aba71
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/media/usb/gspca/m5602/m5602_po1030.c
Expand Up @@ -155,6 +155,7 @@ static const struct v4l2_ctrl_config po1030_greenbal_cfg = {
int po1030_probe(struct sd *sd)
{
u8 dev_id_h = 0, i;
int err;
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;

if (force_sensor) {
Expand All @@ -173,10 +174,13 @@ int po1030_probe(struct sd *sd)
for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) {
u8 data = preinit_po1030[i][2];
if (preinit_po1030[i][0] == SENSOR)
m5602_write_sensor(sd,
preinit_po1030[i][1], &data, 1);
err = m5602_write_sensor(sd, preinit_po1030[i][1],
&data, 1);
else
m5602_write_bridge(sd, preinit_po1030[i][1], data);
err = m5602_write_bridge(sd, preinit_po1030[i][1],
data);
if (err < 0)
return err;
}

if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1))
Expand Down

0 comments on commit 32aba71

Please sign in to comment.