net: cavium: fix NULL pointer dereference in cavium_ptp_put

Prevent a kernel panic on reboot if ptp_clock is NULL by checking
the ptp pointer before using it.

Signed-off-by: Jan Glauber <[email protected]>
Fixes: 8c56df372b ("net: add support for Cavium PTP coprocessor")
Cc: Radoslaw Biernacki <[email protected]>
Cc: Aleksey Makarov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
Jan Glauber 2018-02-12 18:20:11 +01:00 • committed by David S. Miller
commit 07a2e1cf39

View file

@ -75,6 +75,8 @@ EXPORT_SYMBOL(cavium_ptp_get);
void cavium_ptp_put(struct cavium_ptp *ptp)
{
if (!ptp)
return;
pci_dev_put(ptp->pdev);
}
EXPORT_SYMBOL(cavium_ptp_put);