Skip to contentSkip to conversation

gpib: agilent_82357a: don't check a NULL serial string

PATCH In review Joe Simmons-Talbott 3 participants 4 messages Mar 26 – Apr 19 GPIB drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpib: agilent_82357a: don't check a NULL serial string

The agilent_82357a driver uses the USB device serial string for device matching but does not verify that the string exists before passing it to strcmp().

Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference with devices that don't provide a serial number (iSerialNumber = 0).

Similar to commit aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe").

Found by Claude:sonnet-4.5

---
 drivers/gpib/agilent_82357a/agilent_82357a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpib/agilent_82357a/agilent_82357a.c +1 -1
index e1349afbf933..da046ea40f11 100644
@@ -1298,7 +1298,7 @@ static inline int agilent_82357a_device_match(struct usb_interface *interface,
 	if (gpib_match_device_path(&interface->dev, config->device_path) == 0)
 		return 0;
 	if (config->serial_number &&
-	    strcmp(usbdev->serial, config->serial_number) != 0)
+	    (!usbdev->serial || strcmp(usbdev->serial, config->serial_number) != 0))
 		return 0;
 
 	return 1;
Signature · 1 line
2.53.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 34 lines · Joe Simmons-Talbott

The agilent_82357a driver uses the USB device serial string for device matching but does not verify that the string exists before passing it to strcmp().

Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference with devices that don't provide a serial number (iSerialNumber = 0).

Similar to commit aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe").

Found by Claude:sonnet-4.5

---
 drivers/gpib/agilent_82357a/agilent_82357a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpib/agilent_82357a/agilent_82357a.c +1 -1
index e1349afbf933..da046ea40f11 100644
@@ -1298,7 +1298,7 @@ static inline int agilent_82357a_device_match(struct usb_interface *interface,
 	if (gpib_match_device_path(&interface->dev, config->device_path) == 0)
 		return 0;
 	if (config->serial_number &&
-	    strcmp(usbdev->serial, config->serial_number) != 0)
+	    (!usbdev->serial || strcmp(usbdev->serial, config->serial_number) != 0))
 		return 0;
 
 	return 1;
Signature · 1 line
2.53.0
#2 lore raw
Quoted 31 lines · Dave Penkler
Quoted 30 lines · Joe Simmons-Talbott

The agilent_82357a driver uses the USB device serial string for device matching but does not verify that the string exists before passing it to strcmp().

Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference with devices that don't provide a serial number (iSerialNumber = 0).

Similar to commit aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe").

Found by Claude:sonnet-4.5

---
 drivers/gpib/agilent_82357a/agilent_82357a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpib/agilent_82357a/agilent_82357a.c +1 -1
index e1349afbf933..da046ea40f11 100644
@@ -1298,7 +1298,7 @@ static inline int agilent_82357a_device_match(struct usb_interface *interface,
 	if (gpib_match_device_path(&interface->dev, config->device_path) == 0)
 		return 0;
 	if (config->serial_number &&
-	    strcmp(usbdev->serial, config->serial_number) != 0)
+	    (!usbdev->serial || strcmp(usbdev->serial, config->serial_number) != 0))
 		return 0;
 
Quoted 6 lines
Quoted 4 lines
drivers/gpib/agilent_82357a/agilent_82357a.c +0 -0
 	return 1;
Signature · 1 line
2.53.0

+Greg

Hi Greg,

Sorry I neglected to include you on the original patch submission. Are you able to either take this patch or point me to the proper person?

Thanks,
Joe

#3 lore raw
Quoted 39 lines · Joe Simmons-Talbott
Quoted 31 lines · Dave Penkler
Quoted 30 lines · Joe Simmons-Talbott

The agilent_82357a driver uses the USB device serial string for device matching but does not verify that the string exists before passing it to strcmp().

Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference with devices that don't provide a serial number (iSerialNumber = 0).

Similar to commit aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe").

Found by Claude:sonnet-4.5

---
 drivers/gpib/agilent_82357a/agilent_82357a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpib/agilent_82357a/agilent_82357a.c +1 -1
index e1349afbf933..da046ea40f11 100644
@@ -1298,7 +1298,7 @@ static inline int agilent_82357a_device_match(struct usb_interface *interface,
 	if (gpib_match_device_path(&interface->dev, config->device_path) == 0)
 		return 0;
 	if (config->serial_number &&
-	    strcmp(usbdev->serial, config->serial_number) != 0)
+	    (!usbdev->serial || strcmp(usbdev->serial, config->serial_number) != 0))
 		return 0;
 
Quoted 6 lines
Quoted 4 lines
drivers/gpib/agilent_82357a/agilent_82357a.c +0 -0
 	return 1;
Signature · 1 line
2.53.0
Quoted 6 lines

+Greg

Hi Greg,

Sorry I neglected to include you on the original patch submission. Are you able to either take this patch or point me to the proper person?

I can take it after -rc1 is out, thanks.

greg k-h