usb: gadget: hid: fix error return code in hid_bind()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 18 Jun 2021 04:38:35 +0000 (12:38 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Jun 2021 09:27:54 +0000 (11:27 +0200)
Fix to return a negative error code from the error handling
case instead of 0.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210618043835.2641360-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/legacy/hid.c

index c4eda7fe7ab45a61272096915d10db0b1092b03d..5b27d289443fe2af1feb815243a7b69add588341 100644 (file)
@@ -171,8 +171,10 @@ static int hid_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 put;
+               }
                usb_otg_descriptor_init(gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;