diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 66cc94427437c0b246d423c23fa0cdcf1dcb9561..9006bb3c9e7236dcab78a7f0e60a6082988b8587 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1048,14 +1048,20 @@ static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt) struct rt6_info *nrt; if (!fib6_info_hold_safe(rt)) - return NULL; + goto fallback; nrt = ip6_dst_alloc(dev_net(dev), dev, flags); - if (nrt) - ip6_rt_copy_init(nrt, rt); - else + if (!nrt) { fib6_info_release(rt); + goto fallback; + } + ip6_rt_copy_init(nrt, rt); + return nrt; + +fallback: + nrt = dev_net(dev)->ipv6.ip6_null_entry; + dst_hold(&nrt->dst); return nrt; } @@ -1104,10 +1110,6 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net, dst_hold(&rt->dst); } else { rt = ip6_create_rt_rcu(f6i); - if (!rt) { - rt = net->ipv6.ip6_null_entry; - dst_hold(&rt->dst); - } } rcu_read_unlock();