net: stmmac: fix NULL pointer dereference in stmmac_get_tx_hwtstamp
Subsystems (4)
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
@@ -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
David Miller
maintainerFrom: Bruce Liu <[email protected]>
Date: Wed, 15 Jan 2014 22:26:07 +0800
Quoted 6 lines
When timestamping is enabled,
stmmac_tx_cleanwill callstmmac_get_tx_hwtstampto get tx TS.
But the skb can be NULL because the last of itstx_skbuffis NULL if this packet frame is filled in more than one descriptors.Signed-off-by Bruce Liu <[email protected]>
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.