netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nl80211: [PATCH] nl80211: fix possible memory leak nl80211_connect()
@ 2012-09-02 13:41 Wei Yongjun
  2012-09-04 16:07 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-09-02 13:41 UTC (permalink / raw)
  To: johannes, linville, davem; +Cc: yongjun_wei, linux-wireless, netdev

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

connkeys is malloced in nl80211_parse_connkeys() and should
be freed in the error handling case, otherwise it will cause
memory leak.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 net/wireless/nl80211.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 97026f3..1e37dbf 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5633,8 +5633,10 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 		       sizeof(connect.ht_capa_mask));
 
 	if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
-		if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
+		if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) {
+			kfree(connkeys);
 			return -EINVAL;
+		}
 		memcpy(&connect.ht_capa,
 		       nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
 		       sizeof(connect.ht_capa));

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

* Re: [PATCH] nl80211: [PATCH] nl80211: fix possible memory leak nl80211_connect()
  2012-09-02 13:41 [PATCH] nl80211: [PATCH] nl80211: fix possible memory leak nl80211_connect() Wei Yongjun
@ 2012-09-04 16:07 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2012-09-04 16:07 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: linville, davem, yongjun_wei, linux-wireless, netdev

On Sun, 2012-09-02 at 21:41 +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> connkeys is malloced in nl80211_parse_connkeys() and should
> be freed in the error handling case, otherwise it will cause
> memory leak.
> 
> spatch with a semantic match is used to found this problem.
> (http://coccinelle.lip6.fr/)

Applied, thanks. I fixed the subject for you :)

johannes

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

end of thread, other threads:[~2012-09-04 16:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-02 13:41 [PATCH] nl80211: [PATCH] nl80211: fix possible memory leak nl80211_connect() Wei Yongjun
2012-09-04 16:07 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).