Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptp: ocp: Fix error path for pci_ocp_device_init()

If ptp_ocp_device_init() fails, pci_disable_device() is skipped.
Fix the error handling so this case is covered. Update ptp_ocp_remove()
so the normal exit path is identical.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 773bda964921 ("ptp: ocp: Expose various resources on the timecard.")
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jonathan Lemon and committed by
Jakub Kicinski
d9fdbf13 7c807572

+4 -3
+4 -3
drivers/ptp/ptp_ocp.c
··· 1438 1438 bp = devlink_priv(devlink); 1439 1439 err = ptp_ocp_device_init(bp, pdev); 1440 1440 if (err) 1441 - goto out_unregister; 1441 + goto out_disable; 1442 1442 1443 1443 /* compat mode. 1444 1444 * Older FPGA firmware only returns 2 irq's. ··· 1476 1476 1477 1477 out: 1478 1478 ptp_ocp_detach(bp); 1479 - pci_disable_device(pdev); 1480 1479 pci_set_drvdata(pdev, NULL); 1480 + out_disable: 1481 + pci_disable_device(pdev); 1481 1482 out_unregister: 1482 1483 devlink_unregister(devlink); 1483 1484 out_free: ··· 1494 1493 struct devlink *devlink = priv_to_devlink(bp); 1495 1494 1496 1495 ptp_ocp_detach(bp); 1497 - pci_disable_device(pdev); 1498 1496 pci_set_drvdata(pdev, NULL); 1497 + pci_disable_device(pdev); 1499 1498 1500 1499 devlink_unregister(devlink); 1501 1500 devlink_free(devlink);