Skip to contentSkip to conversation

net: stmmac: fix NULL pointer dereference in stmmac_get_tx_hwtstamp

PATCH Superseded Bruce Liu 2 participants 2 messages Jan 15, 2014 – Jan 16, 2014

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bruce Liu

author
#0 lore raw

PATCH 1/1 net: stmmac: fix NULL pointer dereference in stmmac_get_tx_hwtstamp

When timestamping is enabled, stmmac_tx_clean will call stmmac_get_tx_hwtstamp to get tx TS.
But the skb can be NULL because the last of its tx_skbuff is NULL if this packet frame is filled in more than one descriptors.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
index 797b56a..47f2287 100644
@@ -332,7 +332,7 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv,
 		return;
 
 	/* exit if skb doesn't support hw tstamp */
-	if (likely(!(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)))
+	if (likely(!skb || !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)))
 		return;
 
 	if (priv->adv_ts)
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

From: Bruce Liu <[email protected]>
Date: Wed, 15 Jan 2014 22:26:07 +0800

Quoted 6 lines

When timestamping is enabled, stmmac_tx_clean will call stmmac_get_tx_hwtstamp to get tx TS.
But the skb can be NULL because the last of its tx_skbuff is NULL if this packet frame is filled in more than one descriptors.

Sometimes the cure is worse than the disease.

Your change means that every multi-segment packet will never have it's timestamp properly recorded, which is of course bogus.

You need to change this code such that the SKB from the first descriptor is maintained so that we can pass it into stmmac_get_tx_hwtstamp() at the appropriate time.

Thanks.