From: Tom Rix Date: Fri, 21 May 2021 19:48:05 +0000 (+0200) Subject: media: atomisp: improve error handling in gc2235_detect() X-Git-Tag: v5.15-rc1~149^2~51^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=280355522d61d106e52cf0536dcf2807a15aec37;p=thirdparty%2Fkernel%2Flinux.git media: atomisp: improve error handling in gc2235_detect() Static analysis reports this representative problem atomisp-gc2235.c:867:20: warning: The right operand of '|' is a garbage value id = ((high << 8) | low); ^ ~~~ When gc2235_read_reg() fails, its return val is never written. For gc2235_detect(), high and low are or-ed and compared with GC2235_ID, 0x2235. Initialize both to 0 and skip checking the read returns, it's errors are not passed up, only -ENODEV is. Link: https://lore.kernel.org/linux-media/20210521194805.2078135-1-trix@redhat.com Signed-off-by: Tom Rix Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c index 9363c1a52ae9b..4d769590f2d32 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c @@ -849,21 +849,14 @@ static int gc2235_get_fmt(struct v4l2_subdev *sd, static int gc2235_detect(struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; - u16 high, low; - int ret; + u16 high = 0, low = 0; u16 id; if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) return -ENODEV; - ret = gc2235_read_reg(client, GC2235_8BIT, - GC2235_SENSOR_ID_H, &high); - if (ret) { - dev_err(&client->dev, "sensor_id_high = 0x%x\n", high); - return -ENODEV; - } - ret = gc2235_read_reg(client, GC2235_8BIT, - GC2235_SENSOR_ID_L, &low); + gc2235_read_reg(client, GC2235_8BIT, GC2235_SENSOR_ID_H, &high); + gc2235_read_reg(client, GC2235_8BIT, GC2235_SENSOR_ID_L, &low); id = ((high << 8) | low); if (id != GC2235_ID) {