[PATCH] caif: fix cfcnfg_add_phy_layer() leaks

From: Jesper Juhl
Date: Mon Oct 24 2011 - 17:56:29 EST


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@xxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxx> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/