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()

[ Upstream commit f150b63 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Zhang Changzhong authored and gregkh committed Dec 31, 2022
1 parent e1359bc commit ecaf934
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
Expand Up @@ -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)
Expand Down

0 comments on commit ecaf934

Please sign in to comment.