summaryrefslogtreecommitdiffstats
path: root/drivers/ptp
diff options
context:
space:
mode:
authorJonathan Lemon <jonathan.lemon@gmail.com>2021-08-05 21:52:43 +0200
committerDavid S. Miller <davem@davemloft.net>2021-08-06 11:41:27 +0200
commitd12f23fa5142594796a0498d11b5f21463060dac (patch)
tree1b0bb70789aca4c8a7df7686401ad69c2f2bbbd4 /drivers/ptp
parentethtool: return error from ethnl_ops_begin if dev is NULL (diff)
downloadlinux-d12f23fa5142594796a0498d11b5f21463060dac.tar.xz
linux-d12f23fa5142594796a0498d11b5f21463060dac.zip
ptp: ocp: Fix the error handling path for the class device.
Move the put_device() call to the error handling path, so the device is released after the .release callback, avoiding a use-after-free. Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/ptp_ocp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 039d3a5c2a6f..261713c6e9a7 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1381,7 +1381,6 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)
err = device_add(&bp->dev);
if (err) {
dev_err(&bp->dev, "device add failed: %d\n", err);
- put_device(&bp->dev);
goto out;
}
@@ -1391,6 +1390,7 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)
out:
ptp_ocp_dev_release(&bp->dev);
+ put_device(&bp->dev);
return err;
}