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

We must return negative error code -ENOMEM if function
'usb_otg_descriptor_alloc()' fails.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Link: https://lore.kernel.org/r/20230621124323.47183-1-harperchen1110@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wei Chen 2023-06-21 12:43:23 +00:00 committed by Greg Kroah-Hartman
parent ef1e29c6f6
commit ff399bab86
1 changed files with 3 additions and 1 deletions

View File

@ -389,8 +389,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;