Skip to content

Commit

Permalink
net: Remove duplicated midx check against 0
Browse files Browse the repository at this point in the history
Check midx against 0 is always equal to check midx against sk_bound_dev_if
when sk_bound_dev_if is known not equal to 0 in these case.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Miaohe Lin authored and David S. Miller committed Aug 25, 2020
1 parent 0ce779a commit fdf1923
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/ipv4/ip_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, int optname,
dev_put(dev);

err = -EINVAL;
if (sk->sk_bound_dev_if &&
(!midx || midx != sk->sk_bound_dev_if))
if (sk->sk_bound_dev_if && midx != sk->sk_bound_dev_if)
break;

inet->uc_index = ifindex;
Expand Down Expand Up @@ -1189,7 +1188,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, int optname,
err = -EINVAL;
if (sk->sk_bound_dev_if &&
mreq.imr_ifindex != sk->sk_bound_dev_if &&
(!midx || midx != sk->sk_bound_dev_if))
midx != sk->sk_bound_dev_if)
break;

inet->mc_index = mreq.imr_ifindex;
Expand Down

0 comments on commit fdf1923

Please sign in to comment.