diff options
author | Roopa Prabhu <roopa@cumulusnetworks.com> | 2015-10-10 11:26:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-12 22:47:34 -0400 |
commit | 8c5b83f0f255542b40a1273c32eb067ec00bb2b2 (patch) | |
tree | 23e666959918629d66d8fcf83116eb2aebeb3c1a /net/ipv6/route.c | |
parent | 99dcc7dfb1960d5e2f1577ff3aad69dfeb6e9787 (diff) |
ipv6 route: use err pointers instead of returning pointer by reference
This patch makes ip6_route_info_create return err pointer instead of
returning the rt pointer by reference as suggested by Dave
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 4320ddcac33f..db5b54ad5912 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1724,21 +1724,21 @@ static int ip6_convert_metrics(struct mx6_config *mxc, | |||
1724 | return -EINVAL; | 1724 | return -EINVAL; |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | int ip6_route_info_create(struct fib6_config *cfg, struct rt6_info **rt_ret) | 1727 | static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg) |
1728 | { | 1728 | { |
1729 | int err; | ||
1730 | struct net *net = cfg->fc_nlinfo.nl_net; | 1729 | struct net *net = cfg->fc_nlinfo.nl_net; |
1731 | struct rt6_info *rt = NULL; | 1730 | struct rt6_info *rt = NULL; |
1732 | struct net_device *dev = NULL; | 1731 | struct net_device *dev = NULL; |
1733 | struct inet6_dev *idev = NULL; | 1732 | struct inet6_dev *idev = NULL; |
1734 | struct fib6_table *table; | 1733 | struct fib6_table *table; |
1735 | int addr_type; | 1734 | int addr_type; |
1735 | int err = -EINVAL; | ||
1736 | 1736 | ||
1737 | if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128) | 1737 | if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128) |
1738 | return -EINVAL; | 1738 | goto out; |
1739 | #ifndef CONFIG_IPV6_SUBTREES | 1739 | #ifndef CONFIG_IPV6_SUBTREES |
1740 | if (cfg->fc_src_len) | 1740 | if (cfg->fc_src_len) |
1741 | return -EINVAL; | 1741 | goto out; |
1742 | #endif | 1742 | #endif |
1743 | if (cfg->fc_ifindex) { | 1743 | if (cfg->fc_ifindex) { |
1744 | err = -ENODEV; | 1744 | err = -ENODEV; |
@@ -1958,9 +1958,7 @@ install_route: | |||
1958 | 1958 | ||
1959 | cfg->fc_nlinfo.nl_net = dev_net(dev); | 1959 | cfg->fc_nlinfo.nl_net = dev_net(dev); |
1960 | 1960 | ||
1961 | *rt_ret = rt; | 1961 | return rt; |
1962 | |||
1963 | return 0; | ||
1964 | out: | 1962 | out: |
1965 | if (dev) | 1963 | if (dev) |
1966 | dev_put(dev); | 1964 | dev_put(dev); |
@@ -1969,20 +1967,21 @@ out: | |||
1969 | if (rt) | 1967 | if (rt) |
1970 | dst_free(&rt->dst); | 1968 | dst_free(&rt->dst); |
1971 | 1969 | ||
1972 | *rt_ret = NULL; | 1970 | return ERR_PTR(err); |
1973 | |||
1974 | return err; | ||
1975 | } | 1971 | } |
1976 | 1972 | ||
1977 | int ip6_route_add(struct fib6_config *cfg) | 1973 | int ip6_route_add(struct fib6_config *cfg) |
1978 | { | 1974 | { |
1979 | struct mx6_config mxc = { .mx = NULL, }; | 1975 | struct mx6_config mxc = { .mx = NULL, }; |
1980 | struct rt6_info *rt = NULL; | 1976 | struct rt6_info *rt; |
1981 | int err; | 1977 | int err; |
1982 | 1978 | ||
1983 | err = ip6_route_info_create(cfg, &rt); | 1979 | rt = ip6_route_info_create(cfg); |
1984 | if (err) | 1980 | if (IS_ERR(rt)) { |
1981 | err = PTR_ERR(rt); | ||
1982 | rt = NULL; | ||
1985 | goto out; | 1983 | goto out; |
1984 | } | ||
1986 | 1985 | ||
1987 | err = ip6_convert_metrics(&mxc, cfg); | 1986 | err = ip6_convert_metrics(&mxc, cfg); |
1988 | if (err) | 1987 | if (err) |
@@ -2871,9 +2870,12 @@ static int ip6_route_multipath_add(struct fib6_config *cfg) | |||
2871 | r_cfg.fc_encap_type = nla_get_u16(nla); | 2870 | r_cfg.fc_encap_type = nla_get_u16(nla); |
2872 | } | 2871 | } |
2873 | 2872 | ||
2874 | err = ip6_route_info_create(&r_cfg, &rt); | 2873 | rt = ip6_route_info_create(&r_cfg); |
2875 | if (err) | 2874 | if (IS_ERR(rt)) { |
2875 | err = PTR_ERR(rt); | ||
2876 | rt = NULL; | ||
2876 | goto cleanup; | 2877 | goto cleanup; |
2878 | } | ||
2877 | 2879 | ||
2878 | err = ip6_route_info_append(&rt6_nh_list, rt, &r_cfg); | 2880 | err = ip6_route_info_append(&rt6_nh_list, rt, &r_cfg); |
2879 | if (err) { | 2881 | if (err) { |