From: Jiri Pirko <jiri@resnulli.us>
To: Zhengchao Shao <shaozhengchao@huawei.com>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
stas.yakovlev@gmail.com, kvalo@kernel.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
linville@tuxdriver.com, weiyongjun1@huawei.com,
yuehaibing@huawei.com
Subject: Re: [PATCH] ipw2200: fix memory leak in ipw_wdev_init()
Date: Thu, 8 Dec 2022 14:00:48 +0100 [thread overview]
Message-ID: <Y5HgAAVpYB9WQbz6@nanopsycho> (raw)
In-Reply-To: <20221208122630.2850534-1-shaozhengchao@huawei.com>
Thu, Dec 08, 2022 at 01:26:30PM CET, shaozhengchao@huawei.com wrote:
>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)) {
While you are at it, how about to take the actual return value of
wiphy_register() into account?
> rc = -EIO;
>+ goto out;
>+ }
>+
>+ return 0;
> out:
>+ kfree(priv->ieee->a_band.channels);
>+ kfree(priv->ieee->bg_band.channels);
> return rc;
> }
>
>--
>2.34.1
>
next prev parent reply other threads:[~2022-12-08 13:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 12:26 [PATCH] ipw2200: fix memory leak in ipw_wdev_init() Zhengchao Shao
2022-12-08 13:00 ` Jiri Pirko [this message]
2022-12-09 1:01 ` shaozhengchao
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=Y5HgAAVpYB9WQbz6@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaozhengchao@huawei.com \
--cc=stas.yakovlev@gmail.com \
--cc=weiyongjun1@huawei.com \
--cc=yuehaibing@huawei.com \
/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