Skip to content

Commit

Permalink
net: stmmac: selftests: fix potential memleak in stmmac_test_arpofflo…
Browse files Browse the repository at this point in the history
…ad()

The skb allocated by stmmac_test_get_arp_skb() hasn't been released in
some error handling case, which will lead to a memory leak. Fix this up
by adding kfree_skb() to release skb.

Compile tested only.

Fixes: 5e3fb0a ("net: stmmac: selftests: Implement the ARP Offload test")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Zhang Changzhong authored and David S. Miller committed Dec 9, 2022
1 parent ae18dcd commit f150b63
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
Original file line number Diff line number Diff line change
@@ -1654,12 +1654,16 @@ static int stmmac_test_arpoffload(struct stmmac_priv *priv)
}

ret = stmmac_set_arp_offload(priv, priv->hw, true, ip_addr);
if (ret)
if (ret) {
kfree_skb(skb);
goto cleanup;
}

ret = dev_set_promiscuity(priv->dev, 1);
if (ret)
if (ret) {
kfree_skb(skb);
goto cleanup;
}

ret = dev_direct_xmit(skb, 0);
if (ret)

0 comments on commit f150b63

Please sign in to comment.