media: dvb: mb86a16: check the return value of mb86a16_read()
authorYuanjun Gong <ruc_gongyuanjun@163.com>
Tue, 25 Jul 2023 03:35:13 +0000 (11:35 +0800)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 10 Aug 2023 05:58:36 +0000 (07:58 +0200)
return an error code if mb86a16_read() gets an unexpected return
value.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: add {} around the else statement]

drivers/media/dvb-frontends/mb86a16.c

index d3e2993..3ec2cb4 100644 (file)
@@ -1487,10 +1487,12 @@ static int mb86a16_set_fe(struct mb86a16_state *state)
                }
        }
 
-       mb86a16_read(state, 0x15, &agcval);
-       mb86a16_read(state, 0x26, &cnmval);
-       dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
-
+       if (mb86a16_read(state, 0x15, &agcval) != 2 ||  mb86a16_read(state, 0x26, &cnmval) != 2) {
+               dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
+               ret = -EREMOTEIO;
+       } else {
+               dprintk(verbose, MB86A16_INFO, 1, "AGC = %02x CNM = %02x", agcval, cnmval);
+       }
        return ret;
 }