[PATCH] net: sched: act_ife: fix memory leak

DORMANTno replies

From: Gustavo A. R. Silva <hidden>
Date: 2018-07-10 14:49:15
Also in: lkml
Subsystem: networking [general], tc subsystem, the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jamal Hadi Salim, Jiri Pirko, Linus Torvalds

In case memory resources for *p* are allocated, release them
before return.

Addresses-Coverity-ID: 1471714 ("Resource leak")
Fixes: 0190c1d452a9 ("net: sched: atomically check-allocate action")
Signed-off-by: Gustavo A. R. Silva <redacted>
---
 net/sched/act_ife.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index a3eef00..3d6e265 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -485,8 +485,10 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
 		return -ENOMEM;
 
 	err = tcf_idr_check_alloc(tn, &parm->index, a, bind);
-	if (err < 0)
+	if (err < 0) {
+		kfree(p);
 		return err;
+	}
 	exists = err;
 	if (exists && bind) {
 		kfree(p);
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help