net: cavium: fix NULL pointer dereference in cavium_ptp_put
authorJan Glauber <jglauber@cavium.com>
Mon, 12 Feb 2018 17:20:11 +0000 (18:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Feb 2018 19:38:37 +0000 (14:38 -0500)
Prevent a kernel panic on reboot if ptp_clock is NULL by checking
the ptp pointer before using it.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Fixes: 8c56df372bc1 ("net: add support for Cavium PTP coprocessor")
Cc: Radoslaw Biernacki <rad@semihalf.com>
Cc: Aleksey Makarov <aleksey.makarov@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/common/cavium_ptp.c

index c87c9c684a337ea3651ac668d693c73a34238a9b..d59497a7bdcebd6e3c93194daf4a073334fab786 100644 (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);