Commit 8f9eed1a authored by Yunsheng Lin's avatar Yunsheng Lin Committed by David S. Miller

net: hns3: fix for skb leak when doing selftest

If hns3_nic_net_xmit does not return NETDEV_TX_BUSY when doing
a loopback selftest, the skb is not freed in hns3_clean_tx_ring
or hns3_nic_net_xmit, which causes skb not freed problem.

This patch fixes it by freeing skb when hns3_nic_net_xmit does
not return NETDEV_TX_OK.

Fixes: c39c4d98 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 75718800
...@@ -250,12 +250,14 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode) ...@@ -250,12 +250,14 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
skb_get(skb); skb_get(skb);
tx_ret = hns3_nic_net_xmit(skb, ndev); tx_ret = hns3_nic_net_xmit(skb, ndev);
if (tx_ret == NETDEV_TX_OK) if (tx_ret == NETDEV_TX_OK) {
good_cnt++; good_cnt++;
else } else {
kfree_skb(skb);
netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n", netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
tx_ret); tx_ret);
} }
}
if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) { if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) {
ret_val = HNS3_NIC_LB_TEST_TX_CNT_ERR; ret_val = HNS3_NIC_LB_TEST_TX_CNT_ERR;
netdev_err(ndev, "mode %d sent fail, cnt=0x%x, budget=0x%x\n", netdev_err(ndev, "mode %d sent fail, cnt=0x%x, budget=0x%x\n",
......
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