From nobody Thu Oct 9 08:15:47 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44141AF0B5; Thu, 19 Jun 2025 14:48:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750344497; cv=none; b=Iob3goA6rAbm0gV0rsFidQ7aqPckz5gSuLxvyHiccMkYc5iNMBy1P1PhSIaS/JZY95vYPna2IL4uyLoKGyfU75UW9QtahMJE+L55dteKWp+0XVnOHAP+eELJ7NyvcBqwxf3eRQGd6dpLfWVE0jWKbEJmjmEk7I2xf/rqdarx98g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750344497; c=relaxed/simple; bh=YjMS2CcpuzRSbboHGnLRakfRmitcWwOqCbDpXu5+n/c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dnc7OqXLD97nvkfLxtBHtbf8vGSE+HeiqMNRDY9t/OODpTL9Oh+CO1Kx16udywBGSZPG5oBUFAPRuT3vIb15JFCJNbF2XHieYj1BB7us9VP6eVJRnkNcTtCZQbBPF0nYpG8ip1veiPb6mIot8C4fMePFVJlhl8xV+6zWi0b18+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bNNf26wL3zRk5T; Thu, 19 Jun 2025 22:43:54 +0800 (CST) Received: from kwepemk100013.china.huawei.com (unknown [7.202.194.61]) by mail.maildlp.com (Postfix) with ESMTPS id D6A8B180B6A; Thu, 19 Jun 2025 22:48:11 +0800 (CST) Received: from localhost.localdomain (10.90.31.46) by kwepemk100013.china.huawei.com (7.202.194.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Jun 2025 22:48:11 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , , , Subject: [PATCH V3 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end Date: Thu, 19 Jun 2025 22:40:54 +0800 Message-ID: <20250619144057.2587576-6-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250619144057.2587576-1-shaojijie@huawei.com> References: <20250619144057.2587576-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk100013.china.huawei.com (7.202.194.61) Content-Type: text/plain; charset="utf-8" From: Jian Shen There are several pointers are freed but not set to NULL, and their lifetime is not end immediately. To avoid misusing there wild pointers, set them to NULL. Signed-off-by: Jian Shen Signed-off-by: Jijie Shao --- ChangeLog: v2 -> v3: - Remove unnecessary pointer set to NULL operation, suggested by Simon Ho= rman. v2: https://lore.kernel.org/all/20250617010255.1183069-1-shaojijie@huawei= .com/ --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/driv= ers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index e0a2ca21ee46..9d7c9523c9e1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5208,6 +5208,7 @@ static void hclge_fd_free_node(struct hclge_dev *hdev, { hlist_del(&rule->rule_node); kfree(rule); + rule =3D NULL; hclge_sync_fd_state(hdev); } =20 @@ -5232,6 +5233,7 @@ static void hclge_update_fd_rule_node(struct hclge_de= v *hdev, new_rule->rule_node.pprev =3D old_rule->rule_node.pprev; memcpy(old_rule, new_rule, sizeof(*old_rule)); kfree(new_rule); + new_rule =3D NULL; break; case HCLGE_FD_DELETED: hclge_fd_dec_rule_cnt(hdev, old_rule->location); @@ -8521,6 +8523,7 @@ static void hclge_update_mac_node(struct hclge_mac_no= de *mac_node, if (mac_node->state =3D=3D HCLGE_MAC_TO_ADD) { list_del(&mac_node->node); kfree(mac_node); + mac_node =3D NULL; } else { mac_node->state =3D HCLGE_MAC_TO_DEL; } @@ -9151,6 +9154,7 @@ static void hclge_uninit_vport_mac_list(struct hclge_= vport *vport, case HCLGE_MAC_TO_ADD: list_del(&mac_node->node); kfree(mac_node); + mac_node =3D NULL; break; } } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/dr= ivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index e3f86638540b..3ffd47b30ad3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -933,6 +933,7 @@ static void hclgevf_update_mac_node(struct hclgevf_mac_= addr_node *mac_node, if (mac_node->state =3D=3D HCLGEVF_MAC_TO_ADD) { list_del(&mac_node->node); kfree(mac_node); + mac_node =3D NULL; } else { mac_node->state =3D HCLGEVF_MAC_TO_DEL; } @@ -2395,6 +2396,7 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) sizeof(int), GFP_KERNEL); if (!hdev->vector_irq) { devm_kfree(&pdev->dev, hdev->vector_status); + hdev->vector_status =3D NULL; pci_free_irq_vectors(pdev); return -ENOMEM; } @@ -2408,6 +2410,8 @@ static void hclgevf_uninit_msi(struct hclgevf_dev *hd= ev) =20 devm_kfree(&pdev->dev, hdev->vector_status); devm_kfree(&pdev->dev, hdev->vector_irq); + hdev->vector_status =3D NULL; + hdev->vector_irq =3D NULL; pci_free_irq_vectors(pdev); } =20 --=20 2.33.0