Skip to contentSkip to conversation

usb: gadget: mass_storage: fix error return code in msg_bind()

PATCH In review Chen Zhou 2 participants 2 messages Nov 12, 2020 – Nov 16, 2020 USB

lore
Share & tools
lore

Chen Zhou

author
#0 lore raw

PATCH v2 1/1 usb: gadget: mass_storage: fix error return code in msg_bind()

Fix to return a negative error code from the error handling case instead of 0 in function msg_bind(), as done elsewhere in this function.

Fixes d86788979761 ("usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities")
---
 drivers/usb/gadget/legacy/mass_storage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/mass_storage.c +3 -1
index 9ed22c5fb7fe..ac1741126619 100644
@@ -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;
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Chen Zhou

Fix to return a negative error code from the error handling case instead of 0 in function msg_bind(), as done elsewhere in this function.

Fixes d86788979761 ("usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities")

Peter

Quoted 23 lines
---
 drivers/usb/gadget/legacy/mass_storage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/mass_storage.c +3 -1
index 9ed22c5fb7fe..ac1741126619 100644
@@ -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;
Signature · 1 line
2.20.1
Signature · 2 lines
Thanks,
Peter Chen