All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: legacy: fix error return code of msg_bind()
@ 2021-03-07  8:49 Jia-Ju Bai
  2021-03-23 11:35 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-07  8:49 UTC (permalink / raw)
  To: balbi, gregkh, weiyongjun1; +Cc: linux-usb, linux-kernel, Jia-Ju Bai

When usb_otg_descriptor_alloc() returns NULL to usb_desc, no error
return code of msg_bind() is assigned.
To fix this bug, status is assigned with -ENOMEM in this case.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/usb/gadget/legacy/mass_storage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c
index 9ed22c5fb7fe..ac1741126619 100644
--- a/drivers/usb/gadget/legacy/mass_storage.c
+++ b/drivers/usb/gadget/legacy/mass_storage.c
@@ -175,8 +175,10 @@ static int msg_bind(struct usb_composite_dev *cdev)
 		struct usb_descriptor_header *usb_desc;
 
 		usb_desc = usb_otg_descriptor_alloc(cdev->gadget);
-		if (!usb_desc)
+		if (!usb_desc) {
+			status = -ENOMEM;
 			goto fail_string_ids;
+		}
 		usb_otg_descriptor_init(cdev->gadget, usb_desc);
 		otg_desc[0] = usb_desc;
 		otg_desc[1] = NULL;
-- 
2.17.1


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

* Re: [PATCH] usb: gadget: legacy: fix error return code of msg_bind()
  2021-03-07  8:49 [PATCH] usb: gadget: legacy: fix error return code of msg_bind() Jia-Ju Bai
@ 2021-03-23 11:35 ` Greg KH
  2021-03-23 12:37   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2021-03-23 11:35 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: balbi, weiyongjun1, linux-usb, linux-kernel

On Sun, Mar 07, 2021 at 12:49:15AM -0800, Jia-Ju Bai wrote:
> When usb_otg_descriptor_alloc() returns NULL to usb_desc, no error
> return code of msg_bind() is assigned.
> To fix this bug, status is assigned with -ENOMEM in this case.
> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>>

These lines are not written correctly :(

Please fix up and resend.

thanks,

greg k-h

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

* Re: [PATCH] usb: gadget: legacy: fix error return code of msg_bind()
  2021-03-23 11:35 ` Greg KH
@ 2021-03-23 12:37   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-23 12:37 UTC (permalink / raw)
  To: Greg KH; +Cc: balbi, weiyongjun1, linux-usb, linux-kernel



On 2021/3/23 19:35, Greg KH wrote:
> On Sun, Mar 07, 2021 at 12:49:15AM -0800, Jia-Ju Bai wrote:
>> When usb_otg_descriptor_alloc() returns NULL to usb_desc, no error
>> return code of msg_bind() is assigned.
>> To fix this bug, status is assigned with -ENOMEM in this case.
>>
>> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn
>> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>>
> These lines are not written correctly :(
>
> Please fix up and resend.

Sorry for the mistake.
I will fix it and send a V2 patch.


Best wishes,
Jia-Ju Bai

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

end of thread, other threads:[~2021-03-23 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07  8:49 [PATCH] usb: gadget: legacy: fix error return code of msg_bind() Jia-Ju Bai
2021-03-23 11:35 ` Greg KH
2021-03-23 12:37   ` Jia-Ju Bai

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.