summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2004-09-09 20:47:28 +0000
committerimp <imp@FreeBSD.org>2004-09-09 20:47:28 +0000
commit4c20551f649ebf1cfd04aa6e91891cbfdcb50dbc (patch)
tree2dab0884391cc7d6c227301c58bf6081e5549513
parent50c75b4cae7cf3bb160f14a7eb47fc5d433e3d73 (diff)
downloadFreeBSD-src-4c20551f649ebf1cfd04aa6e91891cbfdcb50dbc.zip
FreeBSD-src-4c20551f649ebf1cfd04aa6e91891cbfdcb50dbc.tar.gz
Add comments about why we're freeing subdevs (which is completely
redundant at this point and should be retired). Don't free subdevs if we don't attach any devices. This was leaving stale device_t's around. Don't touch the device if it isn't attached since the name isn't meaningful then. Switch from strncpy (properly used) to strlcpy. From a patch submitted by Peter Pentchev
-rw-r--r--sys/dev/usb/usb_subr.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 6b930d1..adeb436 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -905,6 +905,10 @@ usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev,
if (dv) {
return (USBD_NORMAL_COMPLETION);
}
+ /*
+ * Free subdevs so we can reallocate it larger for the number of
+ * interfaces
+ */
tmpdv = dev->subdevs;
dev->subdevs = NULL;
free(tmpdv, M_USB);
@@ -1016,9 +1020,6 @@ usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev,
if (dv != NULL) {
return (USBD_NORMAL_COMPLETION);
}
- tmpdv = dev->subdevs;
- dev->subdevs = 0;
- free(tmpdv, M_USB);
/*
* The generic attach failed, but leave the device as it is.
@@ -1346,11 +1347,13 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di,
di->udi_speed = dev->speed;
if (dev->subdevs != NULL) {
- for (i = 0; dev->subdevs[i] &&
- i < USB_MAX_DEVNAMES; i++) {
- strncpy(di->udi_devnames[i], USBDEVPTRNAME(dev->subdevs[i]),
- USB_MAX_DEVNAMELEN);
- di->udi_devnames[i][USB_MAX_DEVNAMELEN-1] = '\0';
+ for (i = 0; dev->subdevs[i] && i < USB_MAX_DEVNAMES; i++) {
+ if (device_is_attached(dev->subdevs[i]))
+ strlcpy(di->udi_devnames[i],
+ USBDEVPTRNAME(dev->subdevs[i]),
+ USB_MAX_DEVNAMELEN);
+ else
+ di->udi_devnames[i][0] = 0;
}
} else {
i = 0;
OpenPOWER on IntegriCloud