summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2020-05-07 08:13:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-20 09:11:55 +0300
commitdea7c8ebf7303544b04e28ffd8ec120b26550208 (patch)
treebfda0a45f428eb6faa7c86ac0d4619a023abf652
parent82fc349bfd8bfea57ad4174cac6c8851a0a05c13 (diff)
downloadlinux-dea7c8ebf7303544b04e28ffd8ec120b26550208.tar.xz
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 d70e7d43241a..2bac77a6f4b6 100644
--- a/drivers/usb/gadget/legacy/cdc2.c
+++ b/drivers/usb/gadget/legacy/cdc2.c
@@ -183,8 +183,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;