Commit 30abc9cd authored by Christian Eggers's avatar Christian Eggers Committed by Jakub Kicinski

net: dsa: avoid potential use-after-free error

If dsa_switch_ops::port_txtstamp() returns false, clone will be freed
immediately. Shouldn't store a pointer to freed memory.
Signed-off-by: default avatarChristian Eggers <ceggers@arri.de>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Tested-by: default avatarVladimir Oltean <olteanv@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20201119110906.25558-1-ceggers@arri.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2ed03e5a
......@@ -522,10 +522,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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment