usb: gadget: net2280: fix memory leak on probe error handling paths

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>
This commit is contained in:
Evgeny Novikov 2020-07-21 23:15:58 +03:00 коммит произвёл Felipe Balbi
Родитель b2aeb6da3d
Коммит 2468c877da
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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;
}