Skip to contentSkip to conversation

idpf: nullify pointers after they are freed

PATCH In review Li Li 4 participants 5 messages Jan 23 – Feb 13

Subsystems (3)
lore
Share & tools
lore

Li Li

author
#0 lore raw

PATCH v2 1/1 idpf: nullify pointers after they are freed

rss_data->rss_key needs to be nullified after it is freed. Checks like "if (!rss_data->rss_key)" in the code could fail if it is not nullified.

Tested: built and booted the kernel.

Fixes 83f38f210b85 ("idpf: Fix RSS LUT NULL pointer crash on early ethtool operations")

---
Changes in v2:
- Remove the line to nullify vport->q_vector_idxs as it is not necessary.

 drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
index 131a8121839bd..f63ab58428d2e 100644
@@ -1308,6 +1308,7 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
 
 free_rss_key:
 	kfree(rss_data->rss_key);
+	rss_data->rss_key = NULL;
 free_vector_idxs:
 	kfree(vport->q_vector_idxs);
 free_vport:
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Reviewed-by on v2 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Li Li via Intel-wired-lan
Sent: Friday, January 23, 2026 7:58 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Eric Dumazet <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; David Decotigny <[email protected]>; Singhai, Anjali <[email protected]>; Samudrala, Sridhar <[email protected]>; Brian Vazquez <[email protected]>; Li Li <[email protected]>; Tantilov, Emil S <[email protected]>
Subject: [Intel-wired-lan] [PATCH v2] idpf: nullify pointers after they are freed

Quoted 6 lines

rss_data->rss_key needs to be nullified after it is freed. Checks like "if (!rss_data->rss_key)" in the code could fail if it is not nullified.

Tested: built and booted the kernel.

Good day ,Li Li

Can you re-spin v3 and mention the reproduction steps (exact bash commands)? The CALL trace from dmesg also is needed for users/admins to find the fix.

Otherwise, fine

Quoted 27 lines
Fixes 83f38f210b85 ("idpf: Fix RSS LUT NULL pointer crash on early

ethtool operations")

---
Changes in v2:
- Remove the line to nullify vport->q_vector_idxs as it is not necessary.

 drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
index 131a8121839bd..f63ab58428d2e 100644
@@ -1308,6 +1308,7 @@ static struct idpf_vport
 *idpf_vport_alloc(struct idpf_adapter *adapter,
 
 free_rss_key:
 	kfree(rss_data->rss_key);
+	rss_data->rss_key = NULL;
 free_vector_idxs:
 	kfree(vport->q_vector_idxs);

free_vport:
--
2.52.0.457.g6b5491de43-goog

author
#2 lore raw
Quoted 23 lines · Aleksandr
Quoted 23 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Li Li via Intel-wired-lan
Sent: Friday, January 23, 2026 7:58 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Eric Dumazet <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; David Decotigny <[email protected]>; Singhai, Anjali <[email protected]>; Samudrala, Sridhar <[email protected]>; Brian Vazquez <[email protected]>; Li Li <[email protected]>; Tantilov, Emil S <[email protected]>
Subject: [Intel-wired-lan] [PATCH v2] idpf: nullify pointers after they are freed

rss_data->rss_key needs to be nullified after it is freed. Checks like "if (!rss_data->rss_key)" in the code could fail if it is not nullified.

Quoted 6 lines
Quoted 2 lines

Tested: built and booted the kernel.

Good day ,Li Li

Can you re-spin v3 and mention the reproduction steps (exact bash commands)? The CALL trace from dmesg also is needed for users/admins to find the fix.

Thank you for the review. This patch isn't to fix any kernel panics we encountered. It is
just to address a discrepancy I observed between the Google idpf and the upstream idpf
as I was preparing for another patch about to be sent out. So far we haven't seen this
particular dangling pointer cause any issues yet, but it's still a good practice to set it to
NULL because there are other places guarded by this pointer being NULL, and it'd be
great to avoid any race conditions.

Quoted 32 lines

Otherwise, fine

Quoted 27 lines
Fixes 83f38f210b85 ("idpf: Fix RSS LUT NULL pointer crash on early

ethtool operations")

---
Changes in v2:
- Remove the line to nullify vport->q_vector_idxs as it is not necessary.

 drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
index 131a8121839bd..f63ab58428d2e 100644
@@ -1308,6 +1308,7 @@ static struct idpf_vport
 *idpf_vport_alloc(struct idpf_adapter *adapter,
 
 free_rss_key:
      kfree(rss_data->rss_key);
+     rss_data->rss_key = NULL;
 free_vector_idxs:
      kfree(vport->q_vector_idxs);

free_vport:
--
2.52.0.457.g6b5491de43-goog

Tested-by
#3 lore raw
Quoted 50 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Li Li via Intel-wired-lan
Sent: Friday, January 23, 2026 12:01 AM
To: Loktionov, Aleksandr <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Eric Dumazet <[email protected]>; [email protected]; [email protected]; linux- [email protected]; David Decotigny <[email protected]>; Singhai, Anjali <[email protected]>; Samudrala, Sridhar <[email protected]>; Brian Vazquez <[email protected]>; Tantilov, Emil S <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH v2] idpf: nullify pointers after they are freed

Quoted 24 lines · Aleksandr
Quoted 24 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Li Li via Intel-wired-lan
Sent: Friday, January 23, 2026 7:58 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; Eric Dumazet <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; David Decotigny <[email protected]>; Singhai, Anjali <[email protected]>; Samudrala, Sridhar <[email protected]>; Brian Vazquez <[email protected]>; Li Li <[email protected]>; Tantilov, Emil S <[email protected]>
Subject: [Intel-wired-lan] [PATCH v2] idpf: nullify pointers after they are freed

rss_data->rss_key needs to be nullified after it is freed. Checks like "if (!rss_data->rss_key)" in the code could fail if it is not nullified.

Quoted 5 lines
Quoted 2 lines

Tested: built and booted the kernel.

Good day ,Li Li

Can you re-spin v3 and mention the reproduction steps (exact bash

commands)?

Quoted 1 line

The CALL trace from dmesg also is needed for users/admins to find the fix.

Quoted 40 lines

Thank you for the review. This patch isn't to fix any kernel panics we encountered. It is just to address a discrepancy I observed between the Google idpf and the upstream idpf as I was preparing for another patch about to be sent out. So far we haven't seen this particular dangling pointer cause any issues yet, but it's still a good practice to set it to NULL because there are other places guarded by this pointer being NULL, and it'd be great to avoid any race conditions.

Quoted 32 lines

Otherwise, fine

Quoted 27 lines
Fixes 83f38f210b85 ("idpf: Fix RSS LUT NULL pointer crash on early

ethtool operations")

---
Changes in v2:
- Remove the line to nullify vport->q_vector_idxs as it is not necessary.

 drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
index 131a8121839bd..f63ab58428d2e 100644
@@ -1308,6 +1308,7 @@ static struct idpf_vport
 *idpf_vport_alloc(struct idpf_adapter *adapter,
 
 free_rss_key:
      kfree(rss_data->rss_key);
+     rss_data->rss_key = NULL;
 free_vector_idxs:
      kfree(vport->q_vector_idxs);

free_vport:
--
2.52.0.457.g6b5491de43-goog

#4 lore raw
In reply to Li Li
Quoted 8 lines · Li Li via Intel-wired-lan

rss_data->rss_key needs to be nullified after it is freed. Checks like "if (!rss_data->rss_key)" in the code could fail if it is not nullified.

Tested: built and booted the kernel.

Fixes 83f38f210b85 ("idpf: Fix RSS LUT NULL pointer crash on early ethtool operations")

Please add iwl-net for fixes, i.e. [PATCH iwl-net v2] in title.

Marcin

Quoted 20 lines

---
Changes in v2:
- Remove the line to nullify vport->q_vector_idxs as it is not necessary.

 drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
index 131a8121839bd..f63ab58428d2e 100644
@@ -1308,6 +1308,7 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,
 
 free_rss_key:
 	kfree(rss_data->rss_key);
+	rss_data->rss_key = NULL;
 free_vector_idxs:
 	kfree(vport->q_vector_idxs);
 free_vport: