net: hns3: add check NULL address for page pool
authorHao Chen <chenhao288@hisilicon.com>
Fri, 26 Nov 2021 12:03:16 +0000 (20:03 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 26 Nov 2021 19:36:29 +0000 (11:36 -0800)
When page pool is not enabled, its address value is still NULL and page
pool should not be accessed, so add a check for it.

Fixes: 850bfb912a6d ("net: hns3: debugfs add support dumping page pool info")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

index 67364ab..fbb8a5f 100644 (file)
@@ -1106,6 +1106,11 @@ hns3_dbg_page_pool_info(struct hnae3_handle *h, char *buf, int len)
                return -EFAULT;
        }
 
+       if (!priv->ring[h->kinfo.num_tqps].page_pool) {
+               dev_err(&h->pdev->dev, "page pool is not initialized\n");
+               return -EFAULT;
+       }
+
        for (i = 0; i < ARRAY_SIZE(page_pool_info_items); i++)
                result[i] = &data_str[i][0];