Skip to contentSkip to conversation

media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()

PATCH New Anant Thazhemadam 1 participant 1 message Dec 7, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte()

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.

---
 drivers/media/usb/dvb-usb/dibusb-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/dvb-usb/dibusb-common.c +1 -1
index 02b51d1a1b67..aff60c10cb0b 100644
@@ -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;
 
Signature · 1 line
2.25.1