net: rtm_to_ifaddr: free ifa if ifa_cacheinfo processing fails
Subsystems (3)
PATCH 1/1 net: rtm_to_ifaddr: free ifa if ifa_cacheinfo processing fails
Commit 5c766d642 ("ipv4: introduce address lifetime") leaves the ifa resource that was allocated via inet_alloc_ifa() unfreed when returning the function with -EINVAL. Thus, free it first via inet_free_ifa().
--- net/ipv4/devinet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/devinet.c +3 -1
@@ -772,7 +772,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh, ci =nla_data (tb[IFA_CACHEINFO ]);if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) { err = -EINVAL ; - goto errout; + goto errout_free; } *pvalid_lft = ci->ifa_valid; *pprefered_lft = ci->ifa_prefered;
@@ -780,6 +780,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,return ifa; +errout_free: +inet_free_ifa (ifa); errout:return ERR_PTR (err); }
Signature · 1 line
1.7.11.7
Quoted 5 lines · Fri, Aug 02, 2013 at 11:32:43AM CEST, [email protected] wrote:
Commit
5c766d642("ipv4: introduce address lifetime") leaves the ifa resource that was allocated viainet_alloc_ifa()unfreed when returning the function with-EINVAL. Thus, free it first viainet_free_ifa().Signed-off-by Daniel Borkmann <[email protected]>
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Fri, 2 Aug 2013 12:22:29 +0200
Quoted 7 lines
Quoted 5 lines · Fri, Aug 02, 2013 at 11:32:43AM CEST, [email protected] wrote:
Commit
5c766d642("ipv4: introduce address lifetime") leaves the ifa resource that was allocated viainet_alloc_ifa()unfreed when returning the function with-EINVAL. Thus, free it first viainet_free_ifa().Signed-off-by Daniel Borkmann <[email protected]>Reviewed-by Jiri Pirko <[email protected]>
Applied and queued up for -stable, thanks.