lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240122173633.3843715-1-alexious@zju.edu.cn>
Date: Tue, 23 Jan 2024 01:36:33 +0800
From: Zhipeng Lu <alexious@....edu.cn>
To: alexious@....edu.cn
Cc: Jesse Brandeburg <jesse.brandeburg@...el.com>,
	Tony Nguyen <anthony.l.nguyen@...el.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	Piotr Marczak <piotr.marczak@...el.com>,
	Alice Michael <alice.michael@...el.com>,
	Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
	intel-wired-lan@...ts.osuosl.org,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] i40e: fix a memleak in i40e_init_recovery_mode

In i40e_init_recovery_mode, pf->vsi is allocated without free, causing
a memleak. This patch adds deallocation operations for pf->vsi in each
and every error-handling paths after pf->vsi's.

Fixes: 4ff0ee1af016 ("i40e: Introduce recovery mode support")
Signed-off-by: Zhipeng Lu <alexious@....edu.cn>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 1ab8dbe2d880..a2ed6bb3b2dc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -15598,27 +15598,27 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw)
 	v_idx = i40e_vsi_mem_alloc(pf, I40E_VSI_MAIN);
 	if (v_idx < 0) {
 		err = v_idx;
-		goto err_switch_setup;
+		goto err_vsis;
 	}
 	pf->lan_vsi = v_idx;
 	vsi = pf->vsi[v_idx];
 	if (!vsi) {
 		err = -EFAULT;
-		goto err_switch_setup;
+		goto err_vsis;
 	}
 	vsi->alloc_queue_pairs = 1;
 	err = i40e_config_netdev(vsi);
 	if (err)
-		goto err_switch_setup;
+		goto err_vsis;
 	err = register_netdev(vsi->netdev);
 	if (err)
-		goto err_switch_setup;
+		goto err_vsis;
 	vsi->netdev_registered = true;
 	i40e_dbg_pf_init(pf);
 
 	err = i40e_setup_misc_vector_for_recovery_mode(pf);
 	if (err)
-		goto err_switch_setup;
+		goto err_vsis;
 
 	/* tell the firmware that we're starting */
 	i40e_send_version(pf);
@@ -15628,7 +15628,8 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw)
 		  round_jiffies(jiffies + pf->service_timer_period));
 
 	return 0;
-
+err_vsis:
+	kfree(pf->vsi);
 err_switch_setup:
 	i40e_reset_interrupt_capability(pf);
 	timer_shutdown_sync(&pf->service_timer);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ