Commit 64327fc8 authored by Stefano Brivio's avatar Stefano Brivio Committed by David S. Miller

ipv4: Don't override return code from ip_route_input_noref()

After ip_route_input() calls ip_route_input_noref(), another
check on skb_dst() is done, but if this fails, we shouldn't
override the return code from ip_route_input_noref(), as it
could have been more specific (i.e. -EHOSTUNREACH).

This also saves one call to skb_dst_force_safe() and one to
skb_dst() in case the ip_route_input_noref() check fails.
Reported-by: default avatarSabrina Dubroca <sdubroca@redhat.com>
Fixes: 9df16efa ("ipv4: call dst_hold_safe() properly")
Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
Acked-by: default avatarWei Wang <weiwan@google.com>
Acked-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 138e4ad6
...@@ -189,10 +189,11 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, ...@@ -189,10 +189,11 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
rcu_read_lock(); rcu_read_lock();
err = ip_route_input_noref(skb, dst, src, tos, devin); err = ip_route_input_noref(skb, dst, src, tos, devin);
if (!err) if (!err) {
skb_dst_force_safe(skb); skb_dst_force_safe(skb);
if (!skb_dst(skb)) if (!skb_dst(skb))
err = -EINVAL; err = -EINVAL;
}
rcu_read_unlock(); rcu_read_unlock();
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment