From: Davide Caratti Date: Wed, 14 Nov 2018 11:17:25 +0000 (+0100) Subject: net/sched: act_pedit: fix memory leak when IDR allocation fails X-Git-Tag: rel_imx_4.19.35_1.1.0~8490 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=ae06e2f9c1777592c13910dda9d25d9fd5c1381a;p=linux.git net/sched: act_pedit: fix memory leak when IDR allocation fails [ Upstream commit 19ab69107d3ecfb7cd3e38ad262a881be40c01a3 ] tcf_idr_check_alloc() can return a negative value, on allocation failures (-ENOMEM) or IDR exhaustion (-ENOSPC): don't leak keys_ex in these cases. Fixes: 0190c1d452a9 ("net: sched: atomically check-allocate action") Signed-off-by: Davide Caratti Acked-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index ad99a99f11f6..ca535a8585bc 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -201,7 +201,8 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, goto out_release; } } else { - return err; + ret = err; + goto out_free; } p = to_pedit(*a);