Skip to content

Commit

Permalink
ipv6: fix incorrect bitwise operator used on rt6i_flags
Browse files Browse the repository at this point in the history
The use of the | operator always leads to true which looks rather
suspect to me. Fix this by using & instead to just check the
RTF_CACHE entry bit.

Detected by CoverityScan, CID#1457734, #1457747 ("Wrong operator used")

Fixes: 35732d0 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Wei Wang <weiwan@google.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and David S. Miller committed Oct 10, 2017
1 parent b2427e6 commit 442d713
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ int rt6_remove_exception_rt(struct rt6_info *rt)
int err;

if (!from ||
!(rt->rt6i_flags | RTF_CACHE))
!(rt->rt6i_flags & RTF_CACHE))
return -EINVAL;

if (!rcu_access_pointer(from->rt6i_exception_bucket))
Expand Down Expand Up @@ -1459,7 +1459,7 @@ static void rt6_update_exception_stamp_rt(struct rt6_info *rt)
struct rt6_exception *rt6_ex;

if (!from ||
!(rt->rt6i_flags | RTF_CACHE))
!(rt->rt6i_flags & RTF_CACHE))
return;

rcu_read_lock();
Expand Down

0 comments on commit 442d713

Please sign in to comment.