From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Tue, 15 Apr 2014 15:00:44 +0200 Subject: [U-Boot] [PATCH v3 2/5] usb: handle NULL table in usb_gadget_get_string In-Reply-To: <1397157488-8695-3-git-send-email-robherring2@gmail.com> References: <1397157488-8695-1-git-send-email-robherring2@gmail.com> <1397157488-8695-3-git-send-email-robherring2@gmail.com> Message-ID: <20140415150044.6427b4e0@amdc2363> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Rob, > From: Rob Herring > > Allow a NULL table to be passed to usb_gadget_get_string for cases > when a string table may not be populated. I might be wrong, since I'm not the native speaker, but this description is a bit misleading. For me this patch is supposed to prevent from using uninitialized string table in this function. > > Signed-off-by: Rob Herring > --- > 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; Despite the problem with parsing commit message :-) Acked-by: Lukasz Majewski -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group