When hns3_get_vector_ring_chain() failed in the
hns3_nic_init_vector_data(), it should do the error handling instead
of return directly.
Also, cur_chain should be freed instead of chain and head->next should
be set to NULL in error handling of hns3_get_vector_ring_chain.
This patch fixes them.
Fixes: 73b907a083b8 ("net: hns3: bugfix for buffer not free problem during resetting")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
        cur_chain = head->next;
        while (cur_chain) {
                chain = cur_chain->next;
-               devm_kfree(&pdev->dev, chain);
+               devm_kfree(&pdev->dev, cur_chain);
                cur_chain = chain;
        }
+       head->next = NULL;
 
        return -ENOMEM;
 }
                ret = hns3_get_vector_ring_chain(tqp_vector,
                                                 &vector_ring_chain);
                if (ret)
-                       return ret;
+                       goto map_ring_fail;
 
                ret = h->ae_algo->ops->map_ring_to_vector(h,
                        tqp_vector->vector_irq, &vector_ring_chain);