Commit d12f23fa authored by Jonathan Lemon's avatar Jonathan Lemon Committed by David S. Miller

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: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 596690e9
...@@ -1381,7 +1381,6 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev) ...@@ -1381,7 +1381,6 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)
err = device_add(&bp->dev); err = device_add(&bp->dev);
if (err) { if (err) {
dev_err(&bp->dev, "device add failed: %d\n", err); dev_err(&bp->dev, "device add failed: %d\n", err);
put_device(&bp->dev);
goto out; goto out;
} }
...@@ -1391,6 +1390,7 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev) ...@@ -1391,6 +1390,7 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)
out: out:
ptp_ocp_dev_release(&bp->dev); ptp_ocp_dev_release(&bp->dev);
put_device(&bp->dev);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment