public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipw2200: fix memory leak in ipw_wdev_init()
@ 2022-12-08 12:26 Zhengchao Shao
  2022-12-08 13:00 ` Jiri Pirko
  0 siblings, 1 reply; 3+ messages in thread
From: Zhengchao Shao @ 2022-12-08 12:26 UTC (permalink / raw)
  To: linux-wireless, netdev, stas.yakovlev, kvalo, davem, edumazet,
	kuba, pabeni
  Cc: linville, weiyongjun1, yuehaibing, shaozhengchao

In the error path of ipw_wdev_init(), exception value is returned, and
the memory applied for in the function is not released. Also the memory
is not released in ipw_pci_probe(). As a result, memory leakage occurs.
So memory release needs to be added to the error path of ipw_wdev_init().

Fixes: a3caa99e6c68 ("libipw: initiate cfg80211 API conversion (v2)")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
index 5b483de18c81..cead5c7fc91e 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
@@ -11397,9 +11397,15 @@ static int ipw_wdev_init(struct net_device *dev)
 	set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev);
 
 	/* With that information in place, we can now register the wiphy... */
-	if (wiphy_register(wdev->wiphy))
+	if (wiphy_register(wdev->wiphy)) {
 		rc = -EIO;
+		goto out;
+	}
+
+	return 0;
 out:
+	kfree(priv->ieee->a_band.channels);
+	kfree(priv->ieee->bg_band.channels);
 	return rc;
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2022-12-09  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-08 12:26 [PATCH] ipw2200: fix memory leak in ipw_wdev_init() Zhengchao Shao
2022-12-08 13:00 ` Jiri Pirko
2022-12-09  1:01   ` shaozhengchao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox