Skip to content

Commit aa79f99

Browse files
jhovoldAndi Shyti
authored andcommitted
i2c: cp2615: fix serial string NULL-deref at probe
The cp2615 driver uses the USB device serial string as the i2c adapter name but does not make sure that the string exists. Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference (e.g. with malicious devices). Fixes: 4a76954 ("i2c: cp2615: add i2c driver for Silicon Labs' CP2615 Digital Audio Bridge") Cc: [email protected] # 5.13 Cc: Bence Csókás <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Bence Csókás <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f338e77 commit aa79f99

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/i2c/busses/i2c-cp2615.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id)
298298
if (!adap)
299299
return -ENOMEM;
300300

301+
if (!usbdev->serial)
302+
return -EINVAL;
303+
301304
strscpy(adap->name, usbdev->serial, sizeof(adap->name));
302305
adap->owner = THIS_MODULE;
303306
adap->dev.parent = &usbif->dev;

0 commit comments

Comments
 (0)