net: macb: Add a NULL check on desc_ptp
authorHarini Katakam <harini.katakam@xilinx.com>
Tue, 24 Aug 2021 10:02:09 +0000 (15:32 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Aug 2021 09:39:17 +0000 (10:39 +0100)
commit85520079afce885b80647fbd0d13d8f03d057167
tree09c1278ce7c20983c5f5dc25fe109fc02a53339e
parent2d26f6e39afb88d32b8f39e76a51b542c3c51674
net: macb: Add a NULL check on desc_ptp

macb_ptp_desc will not return NULL under most circumstances with correct
Kconfig and IP design config register. But for the sake of the extreme
corner case, check for NULL when using the helper. In case of rx_tstamp,
no action is necessary except to return (similar to timestamp disabled)
and warn. In case of TX, return -EINVAL to let the skb be free. Perform
this check before marking skb in progress.
Fixes coverity warning:
(4) Event dereference:
Dereferencing a null pointer "desc_ptp"

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cadence/macb_ptp.c