saa7134: Unchecked i2c_transfer function result fixed
authorAleksandr Burakov <a.burakov@rosalinux.ru>
Fri, 16 Feb 2024 12:40:06 +0000 (15:40 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 15 Jun 2024 08:49:20 +0000 (10:49 +0200)
Return value of function 'i2c_transfer' is not checked that
may cause undefined behaviour.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 2cf36ac44730 ("[PATCH] v4l: 656: added support for the following cards")
Signed-off-by: Aleksandr Burakov <a.burakov@rosalinux.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/pci/saa7134/saa7134-dvb.c

index 9c6cfef03331d09e5a2801fbf3028f3b47272a90..a66df6adfaad8c9d89390420e2a9350b84a32d2d 100644 (file)
@@ -466,7 +466,9 @@ static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
        /* switch the board to analog mode */
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
-       i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
+       if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
+               return -EIO;
+
        return 0;
 }
 
@@ -1018,7 +1020,9 @@ static int md8800_set_voltage2(struct dvb_frontend *fe,
        else
                wbuf[1] = rbuf & 0xef;
        msg[0].len = 2;
-       i2c_transfer(&dev->i2c_adap, msg, 1);
+       if (i2c_transfer(&dev->i2c_adap, msg, 1) != 1)
+               return -EIO;
+
        return 0;
 }