From 301d4594bf1b0b1e8bbb3c5c248dbd82174cd1a2 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Sat, 21 May 2016 10:40:46 +0000 Subject: 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@ --- sys/dev/usb/usb_subr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sys/dev/usb/usb_subr.c') 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; } -- cgit v1.2.3