dpaa2-eth: fix a possible null pointer dereference
authorRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Mon, 31 May 2021 10:30:04 +0000 (13:30 +0300)
committerXiaobo Xie <xiaobo.xie@nxp.com>
Wed, 2 Jun 2021 10:00:08 +0000 (12:00 +0200)
In case the FD that we are cleaning up on the Tx confirmation path
is corrupted (carries a wrong SWA type), there will be no skb
to work with.

Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

index 1ee793e..b15c13e 100644 (file)
@@ -1092,6 +1092,12 @@ static void dpaa2_eth_free_tx_fd(struct dpaa2_eth_priv *priv,
                return;
        }
 
+       /* If there is no skb (in case of a wrong SWA type)
+        * just exit the function
+        */
+       if (!skb)
+               return;
+
        /* Get the timestamp value */
        if (skb->cb[0] == TX_TSTAMP) {
                struct skb_shared_hwtstamps shhwtstamps;