Skip to content

Commit

Permalink
usb: gadget: legacy: fix error return code in gncm_bind()
Browse files Browse the repository at this point in the history
If 'usb_otg_descriptor_alloc()' fails, we must return a
negative error code -ENOMEM, not 0.

Fixes: 1156e91 ("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>
  • Loading branch information
Wei Yongjun authored and Felipe Balbi committed May 9, 2020
1 parent e8f7f9e commit e27d4b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/gadget/legacy/ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,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;
Expand Down

0 comments on commit e27d4b3

Please sign in to comment.