aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2020-05-07 05:13:32 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-20 08:20:36 +0200
commit5e553801462b8292be85a007f4441f30299b52b5 (patch)
treee726336bf0f02f451ef3b88361269b8affec29f8
parent7e5c1db8ad153a08c4fba3451f7a9088227ba934 (diff)
downloadlinux-yocto-5e553801462b8292be85a007f4441f30299b52b5.tar.gz
linux-yocto-5e553801462b8292be85a007f4441f30299b52b5.tar.bz2
linux-yocto-5e553801462b8292be85a007f4441f30299b52b5.zip
usb: gadget: legacy: fix error return code in cdc_bind()
commit e8f7f9e3499a6d96f7f63a4818dc7d0f45a7783b upstream. If 'usb_otg_descriptor_alloc()' fails, we must return a negative error code -ENOMEM, not 0. Fixes: ab6796ae9833 ("usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/gadget/legacy/cdc2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c
index 8d7a556ece30..563363aba48f 100644
--- a/drivers/usb/gadget/legacy/cdc2.c
+++ b/drivers/usb/gadget/legacy/cdc2.c
@@ -179,8 +179,10 @@ static int cdc_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 fail1;
+ }
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;