net: ethernet: Check that device has PTP clock before access

Avoid null pointer access by checking that Ethernet device has
PTP clock before trying to get the actual PTP clock device.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-05-15 14:57:33 +03:00
commit f7d584a0ce

View file

@ -1038,6 +1038,10 @@ struct device *net_eth_get_ptp_clock(struct net_if *iface)
return NULL;
}
if (!api->get_ptp_clock) {
return NULL;
}
return api->get_ptp_clock(net_if_get_device(iface));
}
#endif /* CONFIG_PTP_CLOCK */