From: Larry Finger <Larry.Finger@lwfinger.net>
To: Jesper Juhl <jj@chaosbits.net>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Andrea Merello <andreamrl@tiscali.it>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sean MacLennan <seanm@seanm.ca>,
Mike McCormack <mikem@ring3k.org>
Subject: Re: [PATCH] Staging, rtl8192e, softmac: remove redundant memset and fix mem leak
Date: Mon, 13 Feb 2012 15:47:47 -0600 [thread overview]
Message-ID: <4F398503.7020200@lwfinger.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1202130012140.13814@swampdragon.chaosbits.net>
On 02/12/2012 05:15 PM, Jesper Juhl wrote:
> In drivers/staging/rtl8192e/rtllib_softmac.c::rtllib_rx_assoc_resp()
> we allocate memory for 'network' with kzalloc() and then proceed to
> zero the already zeroed mem we got from kzalloc() with
> memset(). That's redundant, so remove the memset()
>
> We also fail to kfree() the memory we allocated for 'network' if we do not enter
>
> if (ieee->current_network.qos_data.supported == 1) {
>
> and the variable then goes out of scope.
>
> To fix that I simply moved the kfree() that was inside that 'if'
> statement to instead be just after it. It then covers both the case
> where we take the branch and when we don't.
>
> Signed-off-by: Jesper Juhl<jj@chaosbits.net>
> ---
> drivers/staging/rtl8192e/rtllib_softmac.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> Compile tested only.
ACKed-by: Larry Finger <Larry.Finger@lwfinger.net>
Thanks,
Larry
>
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
> index 1637f11..c5a15db 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac.c
> @@ -2234,7 +2234,6 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
>
> if (!network)
> return 1;
> - memset(network, 0, sizeof(*network));
> ieee->state = RTLLIB_LINKED;
> ieee->assoc_id = aid;
> ieee->softmac_stats.rx_ass_ok++;
> @@ -2259,8 +2258,8 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
> ieee->handle_assoc_response(ieee->dev,
> (struct rtllib_assoc_response_frame *)header,
> network);
> - kfree(network);
> }
> + kfree(network);
>
> kfree(ieee->assocresp_ies);
> ieee->assocresp_ies = NULL;
next prev parent reply other threads:[~2012-02-13 21:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-12 23:15 [PATCH] Staging, rtl8192e, softmac: remove redundant memset and fix mem leak Jesper Juhl
2012-02-13 21:47 ` Larry Finger [this message]
2012-02-14 2:10 ` Sean MacLennan
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=4F398503.7020200@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=andreamrl@tiscali.it \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mikem@ring3k.org \
--cc=seanm@seanm.ca \
/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