media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()
authorAnant Thazhemadam <anant.thazhemadam@gmail.com>
Mon, 7 Dec 2020 06:16:06 +0000 (07:16 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 8 Oct 2021 11:54:43 +0000 (13:54 +0200)
In dibusb_read_eeprom_byte(), if dibusb_i2c_msg() fails, val gets
assigned an value that's not properly initialized.
Using kzalloc() in place of kmalloc() for the buffer fixes this issue,
as the val can now be set to 0 in the event dibusb_i2c_msg() fails.

Reported-by: syzbot+e27b4fd589762b0b9329@syzkaller.appspotmail.com
Tested-by: syzbot+e27b4fd589762b0b9329@syzkaller.appspotmail.com
Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/usb/dvb-usb/dibusb-common.c

index 02b51d1..aff60c1 100644 (file)
@@ -223,7 +223,7 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
        u8 *buf;
        int rc;
 
-       buf = kmalloc(2, GFP_KERNEL);
+       buf = kzalloc(2, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;