diff options
author | Wei Yongjun <weiyongjun1@huawei.com> | 2020-05-07 08:13:32 +0300 |
---|---|---|
committer | Felipe Balbi <balbi@kernel.org> | 2020-05-09 11:05:08 +0300 |
commit | e8f7f9e3499a6d96f7f63a4818dc7d0f45a7783b (patch) | |
tree | 63dc04d8dce549ac63fe49102013173413c3c862 /drivers/usb/gadget/legacy | |
parent | d13cce757954fa663c69845611957396843ed87a (diff) | |
download | linux-e8f7f9e3499a6d96f7f63a4818dc7d0f45a7783b.tar.xz |
usb: gadget: legacy: fix error return code in cdc_bind()
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>
Diffstat (limited to 'drivers/usb/gadget/legacy')
-rw-r--r-- | drivers/usb/gadget/legacy/cdc2.c | 4 |
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; |