[U-Boot] [PATCH v3 2/5] usb: handle NULL table in usb_gadget_get_string

Rob Herring robherring2 at gmail.com
Thu Apr 10 21:18:04 CEST 2014


From: Rob Herring <robh at kernel.org>

Allow a NULL table to be passed to usb_gadget_get_string for cases
when a string table may not be populated.

Signed-off-by: Rob Herring <robh at kernel.org>
---
 drivers/usb/gadget/usbstring.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index de5fa3f..8c3ff64 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -108,6 +108,9 @@ usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf)
 	struct usb_string	*s;
 	int			len;
 
+	if (!table)
+		return -EINVAL;
+
 	/* descriptor 0 has the language id */
 	if (id == 0) {
 		buf[0] = 4;
-- 
1.9.1



More information about the U-Boot mailing list