media: dw2102: fix a potential buffer overflow
authorMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 29 Apr 2024 14:15:05 +0000 (15:15 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 29 Apr 2024 18:04:03 +0000 (19:04 +0100)
As pointed by smatch:
 drivers/media/usb/dvb-usb/dw2102.c:802 su3000_i2c_transfer() error: __builtin_memcpy() '&state->data[4]' too small (64 vs 67)

That seemss to be due to a wrong copy-and-paste.

Fixes: 0e148a522b84 ("media: dw2102: Don't translate i2c read into write")
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/usb/dvb-usb/dw2102.c

index 03b411ad64bbcea47442b49b1b94230017f5addd..79e2ccf974c927d1efdf016412f4ebb2fc039c92 100644 (file)
@@ -789,7 +789,7 @@ static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 
                        if (msg[j].flags & I2C_M_RD) {
                                /* single read */
-                               if (1 + msg[j].len > sizeof(state->data)) {
+                               if (4 + msg[j].len > sizeof(state->data)) {
                                        warn("i2c rd: len=%d is too big!\n", msg[j].len);
                                        num = -EOPNOTSUPP;
                                        break;