From: Johannes Berg <johannes@sipsolutions.net>
To: Dinh Nguyen <dinguyen@kernel.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wifi: cfg80211: fix a possible memory leak
Date: Thu, 01 Dec 2022 15:21:57 +0100 [thread overview]
Message-ID: <7b5cadba428b153cca5fed84cd4ccc25e31c9334.camel@sipsolutions.net> (raw)
In-Reply-To: <20221101201931.119136-1-dinguyen@kernel.org>
On Tue, 2022-11-01 at 15:19 -0500, Dinh Nguyen wrote:
> Klockworks
>
You probably mean "klocwork" :)
> reported a possible memory leak when
> cfg80211_inform_single_bss_data() return on an error and ies is left
> allocated.
>
> Fixes: 0e227084aee3 ("cfg80211: clarify BSS probe response vs. beacon data")
> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
> ---
> net/wireless/scan.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/wireless/scan.c b/net/wireless/scan.c
> index 806a5f1330ff..3c81dc17e079 100644
> --- a/net/wireless/scan.c
> +++ b/net/wireless/scan.c
> @@ -2015,8 +2015,10 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
>
> signal_valid = data->chan == channel;
> res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid, ts);
> - if (!res)
> + if (!res) {
> + kfree(ies);
> return NULL;
> + }
>
To be honest this makes me a bit nervous - the function will take over
ownership of the tmp BSS in many cases if not all. Not saying it doesn't
have a bug, but at least one case inside of it *does* free it even in
the case of returning NULL and then you have a double-free?
So I think you didn't look at the code closely enough. Please do check
and follow up with a proper fix.
johannes
prev parent reply other threads:[~2022-12-01 14:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 20:19 Dinh Nguyen
2022-12-01 14:21 ` Johannes Berg [this message]
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=7b5cadba428b153cca5fed84cd4ccc25e31c9334.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=davem@davemloft.net \
--cc=dinguyen@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®