lkml.org 
[lkml]   [2020]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 059/639] net: hns3: add error handler for hns3_nic_init_vector_data()
    Date
    From: Huazhong Tan <tanhuazhong@huawei.com>

    [ Upstream commit ece4bf46e98c9f3775a488f3932a531508d3b1a2 ]

    When hns3_nic_init_vector_data() fails to map ring to vector,
    it should cancel the netif_napi_add() that has been successfully
    done and then exits.

    Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
    Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 ++++++++--
    1 file changed, 8 insertions(+), 2 deletions(-)

    diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
    index 1aaf6e2a3b39d..9df807ec8c840 100644
    --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
    +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
    @@ -2642,7 +2642,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
    struct hnae3_handle *h = priv->ae_handle;
    struct hns3_enet_tqp_vector *tqp_vector;
    int ret = 0;
    - u16 i;
    + int i;

    for (i = 0; i < priv->vector_num; i++) {
    tqp_vector = &priv->tqp_vector[i];
    @@ -2687,13 +2687,19 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
    hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);

    if (ret)
    - return ret;
    + goto map_ring_fail;

    netif_napi_add(priv->netdev, &tqp_vector->napi,
    hns3_nic_common_poll, NAPI_POLL_WEIGHT);
    }

    return 0;
    +
    +map_ring_fail:
    + while (i--)
    + netif_napi_del(&priv->tqp_vector[i].napi);
    +
    + return ret;
    }

    static int hns3_nic_alloc_vector_data(struct hns3_nic_priv *priv)
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-01-24 12:01    [W:2.310 / U:2.624 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site