summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2016-05-21 10:40:46 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2016-05-21 10:40:46 +0000
commit301d4594bf1b0b1e8bbb3c5c248dbd82174cd1a2 (patch)
tree8235cdb1b1373dcdac61b1f51036cff0c08546dd /sys/dev
parent73bd298b9b7be0e52360582c8515cdfd887353c7 (diff)
Free the cache if the string cannot be retrieved. This allows the
fallback method to actually do its work and look up the strings via the vendor and product id. Regression noticed and ok tb@, ok mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/usb_subr.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index bfd4e591b55..9eb460993f2 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.121 2016/05/18 18:28:58 patrick Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.122 2016/05/21 10:40:45 patrick Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -217,8 +217,12 @@ usbd_get_device_string(struct usbd_device *dev, uByte index, char **buf)
{
char *b = malloc(USB_MAX_STRING_LEN, M_USB, M_NOWAIT);
if (b != NULL) {
- usbd_get_string(dev, index, b, USB_MAX_STRING_LEN);
- usbd_trim_spaces(b);
+ if (usbd_get_string(dev, index, b, USB_MAX_STRING_LEN) != NULL)
+ usbd_trim_spaces(b);
+ else {
+ free(b, M_USB, USB_MAX_STRING_LEN);
+ b = NULL;
+ }
}
*buf = b;
}