intel-wired-lan.lists.osuosl.org archive mirror
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
@ 2023-01-11 10:36 Michal Swiatkowski
  2023-01-12 17:02 ` Ertman, David M
  2023-01-24  3:14 ` G, GurucharanX
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Swiatkowski @ 2023-01-11 10:36 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: anthony.l.nguyen, error27

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.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
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(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index a09cb4ac39e4..04f31a83e327 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -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);
-- 
2.36.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
  2023-01-11 10:36 [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays Michal Swiatkowski
@ 2023-01-12 17:02 ` Ertman, David M
  2023-01-12 17:38   ` Ertman, David M
  2023-01-24  3:14 ` G, GurucharanX
  1 sibling, 1 reply; 5+ messages in thread
From: Ertman, David M @ 2023-01-12 17:02 UTC (permalink / raw)
  To: Michal Swiatkowski, intel-wired-lan; +Cc: Nguyen, Anthony L, error27

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Michal Swiatkowski
> Sent: Wednesday, January 11, 2023 2:37 AM
> To: intel-wired-lan@lists.osuosl.org
> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; error27@gmail.com
> 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.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
> 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!

Reviewed-by: Dave Ertman <david.m.ertman@intel.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
  2023-01-12 17:02 ` Ertman, David M
@ 2023-01-12 17:38   ` Ertman, David M
  2023-01-13  6:19     ` Michal Swiatkowski
  0 siblings, 1 reply; 5+ messages in thread
From: Ertman, David M @ 2023-01-12 17:38 UTC (permalink / raw)
  To: Michal Swiatkowski, intel-wired-lan; +Cc: Nguyen, Anthony L, error27

> -----Original Message-----
> From: Ertman, David M
> Sent: Thursday, January 12, 2023 9:03 AM
> To: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>; intel-wired-
> lan@lists.osuosl.org
> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; error27@gmail.com
> Subject: RE: [Intel-wired-lan] [PATCH] ice: memory leak in
> ice_vsi_alloc_stat_arrays
> 
> > -----Original Message-----
> > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> > Michal Swiatkowski
> > Sent: Wednesday, January 11, 2023 2:37 AM
> > To: intel-wired-lan@lists.osuosl.org
> > Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> error27@gmail.com
> > 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.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > ---
> > 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!
> 
> Reviewed-by: Dave Ertman <david.m.ertman@intel.com>

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
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
  2023-01-12 17:38   ` Ertman, David M
@ 2023-01-13  6:19     ` Michal Swiatkowski
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Swiatkowski @ 2023-01-13  6:19 UTC (permalink / raw)
  To: Ertman, David M; +Cc: Nguyen, Anthony L, intel-wired-lan, error27

On Thu, Jan 12, 2023 at 05:38:29PM +0000, Ertman, David M wrote:
> > -----Original Message-----
> > From: Ertman, David M
> > Sent: Thursday, January 12, 2023 9:03 AM
> > To: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>; intel-wired-
> > lan@lists.osuosl.org
> > Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; error27@gmail.com
> > Subject: RE: [Intel-wired-lan] [PATCH] ice: memory leak in
> > ice_vsi_alloc_stat_arrays
> > 
> > > -----Original Message-----
> > > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> > > Michal Swiatkowski
> > > Sent: Wednesday, January 11, 2023 2:37 AM
> > > To: intel-wired-lan@lists.osuosl.org
> > > Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> > error27@gmail.com
> > > 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.
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Reported-by: Dan Carpenter <error27@gmail.com>
> > > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > > ---
> > > 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!
> > 
> > Reviewed-by: Dave Ertman <david.m.ertman@intel.com>
> 
> 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

> DaveE
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
  2023-01-11 10:36 [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays Michal Swiatkowski
  2023-01-12 17:02 ` Ertman, David M
@ 2023-01-24  3:14 ` G, GurucharanX
  1 sibling, 0 replies; 5+ messages in thread
From: G, GurucharanX @ 2023-01-24  3:14 UTC (permalink / raw)
  To: Michal Swiatkowski, intel-wired-lan; +Cc: Nguyen, Anthony L, error27



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Michal Swiatkowski
> Sent: Wednesday, January 11, 2023 4:07 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; error27@gmail.com
> 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.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
> 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(-)
> 

Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-24  3:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 10:36 [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays Michal Swiatkowski
2023-01-12 17:02 ` Ertman, David M
2023-01-12 17:38   ` Ertman, David M
2023-01-13  6:19     ` Michal Swiatkowski
2023-01-24  3:14 ` G, GurucharanX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).