summaryrefslogtreecommitdiffstats
path: root/drivers/ptp
diff options
context:
space:
mode:
authorJonathan Lemon <jonathan.lemon@gmail.com>2021-08-16 15:13:35 -0700
committerJakub Kicinski <kuba@kernel.org>2021-08-16 17:18:39 -0700
commitd9fdbf132dab4d844167004ae4ca979fbebd9871 (patch)
tree63cf896d51e58d81c84da991a0394c1485083f97 /drivers/ptp
parent7c8075728f4df477d94df2e4d23a95ee69ee9493 (diff)
downloadlinux-d9fdbf132dab4d844167004ae4ca979fbebd9871.tar.bz2
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>
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/ptp_ocp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 9e4317d1184f..caf9b37c5eb1 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1438,7 +1438,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
bp = devlink_priv(devlink);
err = ptp_ocp_device_init(bp, pdev);
if (err)
- goto out_unregister;
+ goto out_disable;
/* compat mode.
* Older FPGA firmware only returns 2 irq's.
@@ -1476,8 +1476,9 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
out:
ptp_ocp_detach(bp);
- pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
+out_disable:
+ pci_disable_device(pdev);
out_unregister:
devlink_unregister(devlink);
out_free:
@@ -1493,8 +1494,8 @@ ptp_ocp_remove(struct pci_dev *pdev)
struct devlink *devlink = priv_to_devlink(bp);
ptp_ocp_detach(bp);
- pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
+ pci_disable_device(pdev);
devlink_unregister(devlink);
devlink_free(devlink);