summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2020-05-07 05:13:23 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-20 08:15:42 +0200
commit170cbe87348e0104f89eb0b26be9d3fe131bb0ef (patch)
tree2e994fe3d58dd5294d29d93435486c2af7e6d5d8
parent3fa699ebae128e7ac68e3202cb3195017ee8fc7c (diff)
downloadlinux-stable-170cbe87348e0104f89eb0b26be9d3fe131bb0ef.tar.gz
linux-stable-170cbe87348e0104f89eb0b26be9d3fe131bb0ef.tar.bz2
linux-stable-170cbe87348e0104f89eb0b26be9d3fe131bb0ef.zip
usb: gadget: legacy: fix error return code in gncm_bind()
commit e27d4b30b71c66986196d8a1eb93cba9f602904a upstream. If 'usb_otg_descriptor_alloc()' fails, we must return a negative error code -ENOMEM, not 0. Fixes: 1156e91dd7cc ("usb: gadget: ncm: 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/ncm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c
index 2fb4a847dd52..5448cf4ff588 100644
--- a/drivers/usb/gadget/legacy/ncm.c
+++ b/drivers/usb/gadget/legacy/ncm.c
@@ -162,8 +162,10 @@ static int gncm_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;
+ }
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;