• Yunsheng Lin's avatar
    net: hns3: fix error handling for desc filling · aa9d22dd
    Yunsheng Lin authored
    When desc filling fails in hns3_nic_net_xmit, it will call
    hns3_clear_desc to unmap the dma mapping. But currently the
    ring->next_to_use points to the desc where the desc filling
    or dma mapping return error, which means the desc that
    ring->next_to_use points to has not done the dma mapping,
    the desc that need unmapping is before the ring->next_to_use.
    
    This patch fixes it by calling ring_ptr_move_bw(next_to_use)
    before doing unmapping operation, and set desc_cb->dma to
    zero to avoid freeing it again when unloading.
    
    Also, when filling skb head or frag fails, both need to unmap
    all the way back to next_to_use_head, so remove one desc filling
    error handling.
    
    Fixes: 76ad4f0e ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
    Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
    Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    aa9d22dd
hns3_enet.c 113 KB