lkml.org 
[lkml]   [2019]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.1 244/405] net: hns3: check resetting status in hns3_get_stats()
    Date
    [ Upstream commit c4e401e5a934bb0798ebbba98e08dab129695eff ]

    hns3_get_stats() should check the resetting status firstly,
    since the device will be reinitialized when resetting. If the
    reset has not completed, the hns3_get_stats() may access
    invalid memory.

    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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 5 +++++
    1 file changed, 5 insertions(+)

    diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
    index 359d4731fb2db..ea94b5152963f 100644
    --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
    +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
    @@ -483,6 +483,11 @@ static void hns3_get_stats(struct net_device *netdev,
    struct hnae3_handle *h = hns3_get_handle(netdev);
    u64 *p = data;

    + if (hns3_nic_resetting(netdev)) {
    + netdev_err(netdev, "dev resetting, could not get stats\n");
    + return;
    + }
    +
    if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) {
    netdev_err(netdev, "could not get any statistics\n");
    return;
    --
    2.20.1


    \
     
     \ /
      Last update: 2019-05-30 05:14    [W:4.089 / U:0.488 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site