⬢ DragonFlyBSD Kernel Audit
DF-5299 / fix.diff
← back to finding ↓ download raw
--- a/sys/bus/u4b/usb_device.c
+++ b/sys/bus/u4b/usb_device.c
@@ -2246,11 +2246,16 @@ usbd_get_phys(struct usb_device *udev, char *phys, uint8_t len)
 	if (!phys)
 		return;
 
-	info = device_get_ivars(device_get_parent(udev->bus->bdev));
-	ksnprintf(phys, len, "usb-%02x:%02x:%02x.%x-",
-			info->cfg.domain, info->cfg.bus,
-			info->cfg.slot, info->cfg.func);
+	{
+		device_t hdev = device_get_parent(udev->bus->bdev);
+		info = (hdev != NULL) ? device_get_ivars(hdev) : NULL;
+		if (info != NULL && device_get_devclass(hdev) == devclass_find("pci"))
+			ksnprintf(phys, len, "usb-%02x:%02x:%02x.%x-",
+					info->cfg.domain, info->cfg.bus,
+					info->cfg.slot, info->cfg.func);
+		else
+			ksnprintf(phys, len, "usb-%u-",
+					device_get_unit(udev->bus->bdev));
+	}
 
 	while (udev && udev->device_index != USB_ROOT_HUB_ADDR && index) {
 		no[--index] = udev->port_no;