ipv6: fib6_rules: avoid possible NULL dereference in fib6_rule_action()
[linux-block.git] / net / ipv6 / fib6_rules.c
index 52c04f0ac498123becfdc30af5a90f1b2291934d..9e254de7462fb86bb053353dfaa2715a369a7994 100644 (file)
@@ -233,8 +233,12 @@ static int __fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
        rt = pol_lookup_func(lookup,
                             net, table, flp6, arg->lookup_data, flags);
        if (rt != net->ipv6.ip6_null_entry) {
+               struct inet6_dev *idev = ip6_dst_idev(&rt->dst);
+
+               if (!idev)
+                       goto again;
                err = fib6_rule_saddr(net, rule, flags, flp6,
-                                     ip6_dst_idev(&rt->dst)->dev);
+                                     idev->dev);
 
                if (err == -EAGAIN)
                        goto again;