diff mbox series

usb: gadget: legacy: fix error return code in gfs_bind

Message ID 20230621124323.47183-1-harperchen1110@gmail.com
State New
Headers show
Series usb: gadget: legacy: fix error return code in gfs_bind | expand

Commit Message

Wei Chen June 21, 2023, 12:43 p.m. UTC
We must return negative error code -ENOMEM if function
'usb_otg_descriptor_alloc()' fails.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
---
 drivers/usb/gadget/legacy/g_ffs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c
index ae6d8f7092b8..4592df5e2ea1 100644
--- a/drivers/usb/gadget/legacy/g_ffs.c
+++ b/drivers/usb/gadget/legacy/g_ffs.c
@@ -395,8 +395,10 @@  static int gfs_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) {
+			ret = -ENOMEM;
 			goto error_rndis;
+		}
 		usb_otg_descriptor_init(cdev->gadget, usb_desc);
 		gfs_otg_desc[0] = usb_desc;
 		gfs_otg_desc[1] = NULL;