All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: ether: Fix wrong return value of eth_bind()
@ 2020-11-12 13:48 Zhang Xiaoxu
  2020-11-16 14:03 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Xiaoxu @ 2020-11-12 13:48 UTC (permalink / raw)
  To: zhangxiaoxu5, balbi, linux-usb, gregkh, jun.li

If the otg descriptor allocate failed, we should return -ENOMEM,
rather than the 'status' from 'usb_string_ids_tab'.

Fixes: 9b95236eebdb ("usb: gadget: ether: allocate and init otg descriptor by otg capabilities")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
---
 drivers/usb/gadget/legacy/ether.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c
index 30313b233680..99c7fc0d1d59 100644
--- a/drivers/usb/gadget/legacy/ether.c
+++ b/drivers/usb/gadget/legacy/ether.c
@@ -403,8 +403,10 @@ static int eth_bind(struct usb_composite_dev *cdev)
 		struct usb_descriptor_header *usb_desc;
 
 		usb_desc = usb_otg_descriptor_alloc(gadget);
-		if (!usb_desc)
+		if (!usb_desc) {
+			status = -ENOMEM;
 			goto fail1;
+		}
 		usb_otg_descriptor_init(gadget, usb_desc);
 		otg_desc[0] = usb_desc;
 		otg_desc[1] = NULL;
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: gadget: ether: Fix wrong return value of eth_bind()
  2020-11-12 13:48 [PATCH] usb: gadget: ether: Fix wrong return value of eth_bind() Zhang Xiaoxu
@ 2020-11-16 14:03 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2020-11-16 14:03 UTC (permalink / raw)
  To: Zhang Xiaoxu; +Cc: balbi, linux-usb, gregkh, jun.li

On 20-11-12 08:48:20, Zhang Xiaoxu wrote:
> If the otg descriptor allocate failed, we should return -ENOMEM,
> rather than the 'status' from 'usb_string_ids_tab'.
> 
> Fixes: 9b95236eebdb ("usb: gadget: ether: allocate and init otg descriptor by otg capabilities")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>

Reviewed-by: Peter Chen <peter.chen@nxp.com>

Peter
> ---
>  drivers/usb/gadget/legacy/ether.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c
> index 30313b233680..99c7fc0d1d59 100644
> --- a/drivers/usb/gadget/legacy/ether.c
> +++ b/drivers/usb/gadget/legacy/ether.c
> @@ -403,8 +403,10 @@ static int eth_bind(struct usb_composite_dev *cdev)
>  		struct usb_descriptor_header *usb_desc;
>  
>  		usb_desc = usb_otg_descriptor_alloc(gadget);
> -		if (!usb_desc)
> +		if (!usb_desc) {
> +			status = -ENOMEM;
>  			goto fail1;
> +		}
>  		usb_otg_descriptor_init(gadget, usb_desc);
>  		otg_desc[0] = usb_desc;
>  		otg_desc[1] = NULL;
> -- 
> 2.25.4
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-16 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 13:48 [PATCH] usb: gadget: ether: Fix wrong return value of eth_bind() Zhang Xiaoxu
2020-11-16 14:03 ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.