diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-08-02 05:32:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-02 17:56:06 -0400 |
commit | 446266b0c742a2c9ee8f0dce759a0117bce58a86 (patch) | |
tree | 2ee287031900394357be6297c0729fcd49c196ee | |
parent | 9bb8eeb554795e6fac7cacf7af44bf413e75c9b9 (diff) |
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().
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/devinet.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 8d48c392adcc..34ca6d5a3a4b 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -772,7 +772,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh, | |||
772 | ci = nla_data(tb[IFA_CACHEINFO]); | 772 | ci = nla_data(tb[IFA_CACHEINFO]); |
773 | if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) { | 773 | if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) { |
774 | err = -EINVAL; | 774 | err = -EINVAL; |
775 | goto errout; | 775 | goto errout_free; |
776 | } | 776 | } |
777 | *pvalid_lft = ci->ifa_valid; | 777 | *pvalid_lft = ci->ifa_valid; |
778 | *pprefered_lft = ci->ifa_prefered; | 778 | *pprefered_lft = ci->ifa_prefered; |
@@ -780,6 +780,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh, | |||
780 | 780 | ||
781 | return ifa; | 781 | return ifa; |
782 | 782 | ||
783 | errout_free: | ||
784 | inet_free_ifa(ifa); | ||
783 | errout: | 785 | errout: |
784 | return ERR_PTR(err); | 786 | return ERR_PTR(err); |
785 | } | 787 | } |