]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
usb: gadget: legacy: fix error return code of multi_bind()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sun, 7 Mar 2021 08:45:45 +0000 (00:45 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Mar 2021 11:51:42 +0000 (12:51 +0100)
When usb_otg_descriptor_alloc() returns NULL to usb_desc, no error
return code of multi_bind() is assigned.
To fix this bug, status is assigned with -ENOMEM in this case.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Link: https://lore.kernel.org/r/20210307084545.21775-1-baijiaju1990@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/legacy/multi.c

index ec974984566095a54cbae210b384ff600c2dfdd4..7734bf77b309c5c6a016544d094b6bff7a492905 100644 (file)
@@ -399,8 +399,10 @@ static int __ref multi_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 fail_string_ids;
+               }
                usb_otg_descriptor_init(gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;