Skip to content

Commit

Permalink
USB: gadget: legacy: fix an error code in eth_bind()
Browse files Browse the repository at this point in the history
commit 3e1f4a2 upstream.

This code should return -ENOMEM if the allocation fails but it currently
returns success.

Fixes: 9b95236 ("usb: gadget: ether: allocate and init otg descriptor by otg capabilities")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YBKE9rqVuJEOUWpW@mwanda
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Feb 10, 2021
1 parent d56e0ac commit c8e1dab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/gadget/legacy/ether.c
Expand Up @@ -403,8 +403,10 @@ static int eth_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;
Expand Down

0 comments on commit c8e1dab

Please sign in to comment.