From: Johannes Berg <johannes@sipsolutions.net>
To: Rahul Jain <rahul.jain@samsung.com>
Cc: linux-wireless@vger.kernel.org, Amit Khatri <amit.khatri@samsung.com>
Subject: Re: [PATCH] iw:Fix memory leak if nla_put fails
Date: Wed, 06 Jan 2016 12:11:00 +0100 [thread overview]
Message-ID: <1452078660.2541.7.camel@sipsolutions.net> (raw)
In-Reply-To: <1448617041-20120-1-git-send-email-rahul.jain@samsung.com>
On Fri, 2015-11-27 at 15:07 +0530, Rahul Jain wrote:
>
> @@ -124,7 +124,8 @@ static int handle_coalesce_enable(struct
> nl80211_state *state,
> nla_nest_end(msg, nl_pat);
> free(mask);
> free(pat);
> -
> + pat = NULL;
> + mask = NULL;
I'd prefer to keep the blank line.
> + if (pat)
> + free(pat);
free(NULL) is valid and a no-op.
> - NLA_PUT(msg, NL80211_WOWLAN_TCP_WAKE_MASK,
> - DIV_ROUND_UP(patlen, 8), mask);
> - NLA_PUT(msg,
> NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
> - patlen, pat);
> + if (nla_put(msg,
> NL80211_WOWLAN_TCP_WAKE_MASK,
> + DIV_ROUND_UP(patlen, 8), mask) < 0)
> {
> + free(mask);
> + free(pat);
> + mask = NULL;
> + pat = NULL;
> + goto nla_put_failure;
> + }
> + if (nla_put(msg,
> NL80211_WOWLAN_TCP_WAKE_PAYLOAD,
> + patlen, pat) < 0){
> + free(pat);
> + free(mask);
> + pat = NULL;
> + mask = NULL;
> + goto nla_put_failure;
> + }
I don't understand - you also updated the nla_put_failure label to free
it.
> free(mask);
> free(pat);
seems like you need NULL here though.
johannes
next prev parent reply other threads:[~2016-01-06 11:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 9:37 [PATCH] iw:Fix memory leak if nla_put fails Rahul Jain
2016-01-06 11:11 ` Johannes Berg [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-11-07 11:43 [PATCH] iw: Fix " Amit Khatri
2015-11-07 11:36 Amit Khatri
2015-10-23 22:33 Ola Olsson
2015-11-03 10:28 ` Johannes Berg
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=1452078660.2541.7.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=amit.khatri@samsung.com \
--cc=linux-wireless@vger.kernel.org \
--cc=rahul.jain@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.