* [Intel-wired-lan] [tnguy-next-queue:dev-queue 50/62] drivers/net/ethernet/intel/ice/ice_lib.c:571 ice_vsi_alloc_stat_arrays() warn: possible memory leak of 'vsi_stat'
@ 2023-01-11 4:22 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-01-11 4:22 UTC (permalink / raw)
To: oe-kbuild, Michal Swiatkowski; +Cc: Tony Nguyen, Intel Wired LAN, oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
head: c9ebfbece30b59350bc6879be8ed954cecc6be05
commit: f833ce48581cfdf4b086d7c79cef79191b0a21d2 [50/62] ice: split ice_vsi_setup into smaller functions
config: x86_64-randconfig-m001-20230109
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
New smatch warnings:
drivers/net/ethernet/intel/ice/ice_lib.c:571 ice_vsi_alloc_stat_arrays() warn: possible memory leak of 'vsi_stat'
drivers/net/ethernet/intel/ice/ice_lib.c:2846 ice_vsi_cfg_def() warn: missing error code 'ret'
Old smatch warnings:
drivers/net/ethernet/intel/ice/ice_lib.c:437 ice_vsi_alloc_ring_stats() warn: inconsistent indenting
drivers/net/ethernet/intel/ice/ice_lib.c:3527 ice_vsi_rebuild() warn: missing error code 'ret'
vim +/vsi_stat +571 drivers/net/ethernet/intel/ice/ice_lib.c
288ecf491b1654 Benjamin Mikailenko 2022-11-18 555 static int ice_vsi_alloc_stat_arrays(struct ice_vsi *vsi)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 556 {
288ecf491b1654 Benjamin Mikailenko 2022-11-18 557 struct ice_vsi_stats *vsi_stat;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 558 struct ice_pf *pf = vsi->back;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 559
288ecf491b1654 Benjamin Mikailenko 2022-11-18 560 if (vsi->type == ICE_VSI_CHNL)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 561 return 0;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 562 if (!pf->vsi_stats)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 563 return -ENOENT;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 564
288ecf491b1654 Benjamin Mikailenko 2022-11-18 565 vsi_stat = kzalloc(sizeof(*vsi_stat), GFP_KERNEL);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 566 if (!vsi_stat)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 567 return -ENOMEM;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 568
f833ce48581cfd Michal Swiatkowski 2022-12-21 569 if (vsi_stat->tx_ring_stats && vsi_stat->rx_ring_stats)
f833ce48581cfd Michal Swiatkowski 2022-12-21 570 /* realloc will happen in rebuild path */
f833ce48581cfd Michal Swiatkowski 2022-12-21 @571 return 0;
These aren't allocated until the next line so the return is impossible.
Just delete. But Smatch is correct that it doesn't have a kfree() on
this path...
f833ce48581cfd Michal Swiatkowski 2022-12-21 572
288ecf491b1654 Benjamin Mikailenko 2022-11-18 573 vsi_stat->tx_ring_stats =
288ecf491b1654 Benjamin Mikailenko 2022-11-18 574 kcalloc(vsi->alloc_txq, sizeof(*vsi_stat->tx_ring_stats),
288ecf491b1654 Benjamin Mikailenko 2022-11-18 575 GFP_KERNEL);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 576 if (!vsi_stat->tx_ring_stats)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 577 goto err_alloc_tx;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 578
288ecf491b1654 Benjamin Mikailenko 2022-11-18 579 vsi_stat->rx_ring_stats =
288ecf491b1654 Benjamin Mikailenko 2022-11-18 580 kcalloc(vsi->alloc_rxq, sizeof(*vsi_stat->rx_ring_stats),
288ecf491b1654 Benjamin Mikailenko 2022-11-18 581 GFP_KERNEL);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 582 if (!vsi_stat->rx_ring_stats)
288ecf491b1654 Benjamin Mikailenko 2022-11-18 583 goto err_alloc_rx;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 584
288ecf491b1654 Benjamin Mikailenko 2022-11-18 585 pf->vsi_stats[vsi->idx] = vsi_stat;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 586
288ecf491b1654 Benjamin Mikailenko 2022-11-18 587 return 0;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 588
288ecf491b1654 Benjamin Mikailenko 2022-11-18 589 err_alloc_rx:
288ecf491b1654 Benjamin Mikailenko 2022-11-18 590 kfree(vsi_stat->rx_ring_stats);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 591 err_alloc_tx:
288ecf491b1654 Benjamin Mikailenko 2022-11-18 592 kfree(vsi_stat->tx_ring_stats);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 593 kfree(vsi_stat);
288ecf491b1654 Benjamin Mikailenko 2022-11-18 594 pf->vsi_stats[vsi->idx] = NULL;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 595 return -ENOMEM;
288ecf491b1654 Benjamin Mikailenko 2022-11-18 596 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-11 16:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 4:22 [Intel-wired-lan] [tnguy-next-queue:dev-queue 50/62] drivers/net/ethernet/intel/ice/ice_lib.c:571 ice_vsi_alloc_stat_arrays() warn: possible memory leak of 'vsi_stat' Dan Carpenter
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).