diff mbox

[U-Boot,04/10] g_dnl: Properly terminate string list.

Message ID 1354174439-5589-5-git-send-email-panto@antoniou-consulting.com
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Pantelis Antoniou Nov. 29, 2012, 7:33 a.m. UTC
Well, not terminating the list causes very interesting crashes.
As in changing the vendor & product ID crashes. Fun.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
---
 drivers/usb/gadget/g_dnl.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ɓukasz Majewski Nov. 28, 2012, 3:20 p.m. UTC | #1
Hi Pantelis,

> Well, not terminating the list causes very interesting crashes.
> As in changing the vendor & product ID crashes. Fun.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
>  drivers/usb/gadget/g_dnl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
> index 25da733..a5a4c1f 100644
> --- a/drivers/usb/gadget/g_dnl.c
> +++ b/drivers/usb/gadget/g_dnl.c
> @@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
>  static struct usb_string g_dnl_string_defs[] = {
>  	{ 0, manufacturer, },
>  	{ 1, product, },
> +	{  }		/* end of list */

Thanks for spotting.

>  };
>  
>  static struct usb_gadget_strings g_dnl_string_tab = {

Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Marek Vasut Nov. 29, 2012, 8:20 a.m. UTC | #2
Dear Pantelis Antoniou,

> Well, not terminating the list causes very interesting crashes.
> As in changing the vendor & product ID crashes. Fun.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
>  drivers/usb/gadget/g_dnl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
> index 25da733..a5a4c1f 100644
> --- a/drivers/usb/gadget/g_dnl.c
> +++ b/drivers/usb/gadget/g_dnl.c
> @@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
>  static struct usb_string g_dnl_string_defs[] = {
>  	{ 0, manufacturer, },
>  	{ 1, product, },
> +	{  }		/* end of list */

So you're adding an uninited entry here? How'll this work?

>  };
> 
>  static struct usb_gadget_strings g_dnl_string_tab = {

Best regards,
Marek Vasut
Pantelis Antoniou Nov. 29, 2012, 1:22 p.m. UTC | #3
Hi Marek,

On Nov 29, 2012, at 10:20 AM, Marek Vasut wrote:

> Dear Pantelis Antoniou,
> 
>> Well, not terminating the list causes very interesting crashes.
>> As in changing the vendor & product ID crashes. Fun.
>> 
>> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
>> ---
>> drivers/usb/gadget/g_dnl.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
>> index 25da733..a5a4c1f 100644
>> --- a/drivers/usb/gadget/g_dnl.c
>> +++ b/drivers/usb/gadget/g_dnl.c
>> @@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
>> static struct usb_string[] = {
>> 	{ 0, manufacturer, },
>> 	{ 1, product, },
>> +	{  }		/* end of list */
> 
> So you're adding an uninited entry here? How'll this work?
> 

This is very common idiom. It's not uninitialized, all the members are
set to 0, including the char * members.

It is exactly the same method used in drivers/usb/gadget/ether.c

>> };
>> 
>> static struct usb_gadget_strings g_dnl_string_tab = {
> 
> Best regards,
> Marek Vasut


Regards

-- Pantelis
Marek Vasut Nov. 29, 2012, 2:28 p.m. UTC | #4
Dear Pantelis Antoniou,

> Hi Marek,
> 
> On Nov 29, 2012, at 10:20 AM, Marek Vasut wrote:
> > Dear Pantelis Antoniou,
> > 
> >> Well, not terminating the list causes very interesting crashes.
> >> As in changing the vendor & product ID crashes. Fun.
> >> 
> >> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> >> ---
> >> drivers/usb/gadget/g_dnl.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >> 
> >> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
> >> index 25da733..a5a4c1f 100644
> >> --- a/drivers/usb/gadget/g_dnl.c
> >> +++ b/drivers/usb/gadget/g_dnl.c
> >> @@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
> >> static struct usb_string[] = {
> >> 
> >> 	{ 0, manufacturer, },
> >> 	{ 1, product, },
> >> 
> >> +	{  }		/* end of list */
> > 
> > So you're adding an uninited entry here? How'll this work?
> 
> This is very common idiom. It's not uninitialized, all the members are
> set to 0, including the char * members.
> 
> It is exactly the same method used in drivers/usb/gadget/ether.c

Blah, it's a matter of taste then (I prefer it explicit, but I don't really 
care).

Thanks for clearing this up.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 25da733..a5a4c1f 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -69,6 +69,7 @@  static struct usb_device_descriptor device_desc = {
 static struct usb_string g_dnl_string_defs[] = {
 	{ 0, manufacturer, },
 	{ 1, product, },
+	{  }		/* end of list */
 };
 
 static struct usb_gadget_strings g_dnl_string_tab = {