Skip to content

Commit

Permalink
usb: gadget: net2280: fix memory leak on probe error handling paths
Browse files Browse the repository at this point in the history
Driver does not release memory for device on error handling paths in
net2280_probe() when gadget_release() is not registered yet.

The patch fixes the bug like in other similar drivers.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
  • Loading branch information
Evgeny Novikov authored and Felipe Balbi committed Jul 24, 2020
1 parent b2aeb6d commit 2468c87
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/gadget/udc/net2280.c
Original file line number Diff line number Diff line change
Expand Up @@ -3781,8 +3781,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return 0;

done:
if (dev)
if (dev) {
net2280_remove(pdev);
kfree(dev);
}
return retval;
}

Expand Down

0 comments on commit 2468c87

Please sign in to comment.