mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 02:02:28 +09:00
net: rtm_to_ifaddr: free ifa if ifa_cacheinfo processing fails
[ Upstream commit446266b0c7] Commit5c766d642("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(). Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Reviewed-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f4cc06ac2d
commit
b4f55925ac
@@ -771,7 +771,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;
|
||||
@@ -779,6 +779,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user