From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: anthony.l.nguyen@intel.com, error27@gmail.com
Subject: [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays
Date: Wed, 11 Jan 2023 11:36:30 +0100 [thread overview]
Message-ID: <20230111103630.17629-1-michal.swiatkowski@linux.intel.com> (raw)
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
next reply other threads:[~2023-01-11 11:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 10:36 Michal Swiatkowski [this message]
2023-01-12 17:02 ` [Intel-wired-lan] [PATCH] ice: memory leak in ice_vsi_alloc_stat_arrays 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230111103630.17629-1-michal.swiatkowski@linux.intel.com \
--to=michal.swiatkowski@linux.intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=error27@gmail.com \
--cc=intel-wired-lan@lists.osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox