netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ieee802154: Don't leak memory in ieee802154_nl_fill_phy
@ 2011-06-12 14:28 Jesper Juhl
  2011-06-13 20:02 ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2011-06-12 14:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: netdev, linux-zigbee-devel, David S. Miller, Sergey Lapin,
	Dmitry Eremin-Solenikov, Maxim Osipov

In net/ieee802154/nl-phy.c::ieee802154_nl_fill_phy() I see two small 
issues.
1) If the allocation of 'buf' fails we may just as well return -EMSGSIZE
   directly rather than jumping to 'out:' and do a pointless kfree(0).
2) We do not free 'buf' unless we jump to one of the error labels and this
   leaks memory.
This patch should address both.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 nl-phy.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

  I have no way to properly test this patch, so it's compile tested only.

diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index ed0eab3..02548b2 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -44,7 +44,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid,
 	pr_debug("%s\n", __func__);
 
 	if (!buf)
-		goto out;
+		return -EMSGSIZE;
 
 	hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
 		IEEE802154_LIST_PHY);
@@ -65,6 +65,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid,
 				pages * sizeof(uint32_t), buf);
 
 	mutex_unlock(&phy->pib_lock);
+	kfree(buf);
 	return genlmsg_end(msg, hdr);
 
 nla_put_failure:


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] ieee802154: Don't leak memory in ieee802154_nl_fill_phy
  2011-06-12 14:28 [PATCH] ieee802154: Don't leak memory in ieee802154_nl_fill_phy Jesper Juhl
@ 2011-06-13 20:02 ` Dmitry Eremin-Solenikov
       [not found]   ` <BANLkTikBnQADmUpP7J5gmJLXA9-O+4kSvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-13 20:02 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, netdev, linux-zigbee-devel, David S. Miller,
	Sergey Lapin, Maxim Osipov

On 6/12/11, Jesper Juhl <jj@chaosbits.net> wrote:
> In net/ieee802154/nl-phy.c::ieee802154_nl_fill_phy() I see two small
> issues.
> 1) If the allocation of 'buf' fails we may just as well return -EMSGSIZE
>    directly rather than jumping to 'out:' and do a pointless kfree(0).
> 2) We do not free 'buf' unless we jump to one of the error labels and this
>    leaks memory.
> This patch should address both.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

David, please commit this.

-- 
With best wishes
Dmitry

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

* Re: [PATCH] ieee802154: Don't leak memory in ieee802154_nl_fill_phy
       [not found]   ` <BANLkTikBnQADmUpP7J5gmJLXA9-O+4kSvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-06-13 22:06     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-06-13 22:06 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	maxim.osipov-kv7WeFo6aLtBDgjK7y7TUQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	jj-IYz4IdjRLj0sV2N9l4h3zg

From: Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Tue, 14 Jun 2011 00:02:38 +0400

> On 6/12/11, Jesper Juhl <jj-IYz4IdjRLj0sV2N9l4h3zg@public.gmane.org> wrote:
>> In net/ieee802154/nl-phy.c::ieee802154_nl_fill_phy() I see two small
>> issues.
>> 1) If the allocation of 'buf' fails we may just as well return -EMSGSIZE
>>    directly rather than jumping to 'out:' and do a pointless kfree(0).
>> 2) We do not free 'buf' unless we jump to one of the error labels and this
>>    leaks memory.
>> This patch should address both.
>>
>> Signed-off-by: Jesper Juhl <jj-IYz4IdjRLj0sV2N9l4h3zg@public.gmane.org>
> 
> Acked-by: Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> David, please commit this.

Applied, thanks.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev

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

end of thread, other threads:[~2011-06-13 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-12 14:28 [PATCH] ieee802154: Don't leak memory in ieee802154_nl_fill_phy Jesper Juhl
2011-06-13 20:02 ` Dmitry Eremin-Solenikov
     [not found]   ` <BANLkTikBnQADmUpP7J5gmJLXA9-O+4kSvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-13 22:06     ` David Miller

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).