From: Christian Eggers <ceggers@xxxxxxx> [ Upstream commit 30abc9cd9c6bdd44d23fc49a9c2526a86fba4305 ] If dsa_switch_ops::port_txtstamp() returns false, clone will be freed immediately. Shouldn't store a pointer to freed memory. Signed-off-by: Christian Eggers <ceggers@xxxxxxx> Reviewed-by: Vladimir Oltean <olteanv@xxxxxxxxx> Tested-by: Vladimir Oltean <olteanv@xxxxxxxxx> Reviewed-by: Florian Fainelli <f.fainelli@xxxxxxxxx> Link: https://lore.kernel.org/r/20201119110906.25558-1-ceggers@xxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> --- net/dsa/slave.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index f734ce0bcb56e..2b657e88d8017 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -476,10 +476,10 @@ static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p, if (!clone) return; - DSA_SKB_CB(skb)->clone = clone; - - if (ds->ops->port_txtstamp(ds, p->dp->index, clone, type)) + if (ds->ops->port_txtstamp(ds, p->dp->index, clone, type)) { + DSA_SKB_CB(skb)->clone = clone; return; + } kfree_skb(clone); } -- 2.27.0