netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] caif: fix cfcnfg_add_phy_layer() leaks
@ 2011-10-24 22:01 Jesper Juhl
  2011-10-24 22:36 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-10-24 22:01 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, David S. Miller, Sjur Braendeland

There are two locations where we 'goto out' after having allocated
memory for 'phyinfo' but have not yet assigned it to anything. At the
'out:' label we'll exit from the function and 'phyinfo' will go out of
scope and thus we leak the memory we allocated.

This patch frees the memory before jumping to 'out:', thus fixing the
leaks.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/caif/cfcnfg.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

 compile tested only.

diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
index 52fe33b..b25dc02 100644
--- a/net/caif/cfcnfg.c
+++ b/net/caif/cfcnfg.c
@@ -499,6 +499,7 @@ got_phyid:
 		    cfserl_create(CFPHYTYPE_FRAG, phyid, stx);
 		if (!phy_driver) {
 			pr_warn("Out of memory\n");
+			kfree(phyinfo);
 			goto out;
 		}
 		break;
@@ -506,6 +507,7 @@ got_phyid:
 		phy_driver = NULL;
 		break;
 	default:
+		kfree(phyinfo);
 		goto out;
 	}
 	phy_layer->id = phyid;
-- 
1.7.7


-- 
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] 2+ messages in thread

end of thread, other threads:[~2011-10-24 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 22:01 [PATCH] caif: fix cfcnfg_add_phy_layer() leaks Jesper Juhl
2011-10-24 22:36 ` 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).