Skip to contentSkip to conversation

ice: memory leak in ice_vsi_alloc_stat_arrays

PATCH In review Michal Swiatkowski 3 participants 5 messages Jan 11, 2023 – Jan 24, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: memory leak in ice_vsi_alloc_stat_arrays

Fix memory leak by checking if stats were already allocated before allocating new one.

Previously it was completely broken, because new allocated value was checked instead of previous one.

---
Should be squashed with commit eace2cbe7f5f ("ice: split ice_vsi_setup into smaller functions")

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +4 -4
index a09cb4ac39e4..04f31a83e327 100644
@@ -558,14 +558,14 @@ static int ice_vsi_alloc_stat_arrays(struct ice_vsi *vsi)
 	if (!pf->vsi_stats)
 		return -ENOENT;
 
+	if (pf->vsi_stats[vsi->idx])
+	/* realloc will happen in rebuild path */
+		return 0;
+
 	vsi_stat = kzalloc(sizeof(*vsi_stat), GFP_KERNEL);
 	if (!vsi_stat)
 		return -ENOMEM;
 
-	if (vsi_stat->tx_ring_stats && vsi_stat->rx_ring_stats)
-	/* realloc will happen in rebuild path */
-		return 0;
-
 	vsi_stat->tx_ring_stats =
 		kcalloc(vsi->alloc_txq, sizeof(*vsi_stat->tx_ring_stats),
 			GFP_KERNEL);
Signature · 6 lines
2.36.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Wednesday, January 11, 2023 2:37 AM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Fix memory leak by checking if stats were already allocated before allocating new one.

Previously it was completely broken, because new allocated value was checked instead of previous one.

Quoted 7 lines

---
Should be squashed with commit eace2cbe7f5f ("ice: split ice_vsi_setup into smaller functions")

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Thanks for catching this!

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 36 lines

-----Original Message-----
From: Ertman, David M
Sent: Thursday, January 12, 2023 9:03 AM
To: Michal Swiatkowski <[email protected]>; intel-wired- [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]
Subject: RE: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Quoted 6 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Wednesday, January 11, 2023 2:37 AM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>;

[email protected]

Quoted 12 lines

Subject: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Fix memory leak by checking if stats were already allocated before allocating new one.

Previously it was completely broken, because new allocated value was checked instead of previous one.

Quoted 7 lines

---
Should be squashed with commit eace2cbe7f5f ("ice: split ice_vsi_setup into smaller functions")

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 3 lines

Thanks for catching this!

Please clean-up variable ret, since it is not needed any more. Also can probably clean up braces that won't be needed any more also.

DaveE
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw
Quoted 36 lines · David M
Quoted 36 lines

-----Original Message-----
From: Ertman, David M
Sent: Thursday, January 12, 2023 9:03 AM
To: Michal Swiatkowski <[email protected]>; intel-wired- [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]
Subject: RE: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Quoted 6 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Wednesday, January 11, 2023 2:37 AM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>;

[email protected]

Quoted 19 lines

Subject: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Fix memory leak by checking if stats were already allocated before allocating new one.

Previously it was completely broken, because new allocated value was checked instead of previous one.

---
Should be squashed with commit eace2cbe7f5f ("ice: split ice_vsi_setup into smaller functions")

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 7 lines
Quoted 3 lines

Thanks for catching this!

Please clean-up variable ret, since it is not needed any more. Also can probably clean up braces that won't be needed any more also.

Done, thanks

Quoted 1 line

DaveE

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v1 1/1
#4 lore raw
In reply to Michal Swiatkowski
Quoted 20 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Wednesday, January 11, 2023 4:07 PM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays

Fix memory leak by checking if stats were already allocated before allocating new one.

Previously it was completely broken, because new allocated value was checked instead of previous one.

Quoted 7 lines

---
Should be squashed with commit eace2cbe7f5f ("ice: split ice_vsi_setup into smaller functions")

---
 drivers/net/ethernet/intel/ice/ice_lib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan