Skip to content

Commit

Permalink
net: remove redundant input checks in SIOCSIFTXQLEN case of dev_ifsioc
Browse files Browse the repository at this point in the history
The cited patch added a call to dev_change_tx_queue_len in
SIOCSIFTXQLEN case.
This obsoletes the new len comparison check done before the function call.
Remove it here.

For the desicion of keep/remove the negative value check, we examine the
range check in dev_change_tx_queue_len.
On 64-bit we will fail with -ERANGE.  The 32-bit int ifr_qlen will be sign
extended to 64-bits when it is passed into dev_change_tx_queue_len(). And
then for negative values this test triggers:

	if (new_len != (unsigned int)new_len)
		return -ERANGE;

because:
	if (0xffffffffWHATEVER != 0x00000000WHATEVER)

On 32-bit the signed value will be accepted, changing behavior.

Therefore, the negative value check is kept.

Fixes: 3f76df1 ("net: use dev_change_tx_queue_len() for SIOCSIFTXQLEN")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tariq Toukan authored and davem330 committed Jul 24, 2018
1 parent c4ef85d commit 8dd3020
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions net/core/dev_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
case SIOCSIFTXQLEN:
if (ifr->ifr_qlen < 0)
return -EINVAL;
if (dev->tx_queue_len ^ ifr->ifr_qlen) {
err = dev_change_tx_queue_len(dev, ifr->ifr_qlen);
if (err)
return err;
}
return 0;
return dev_change_tx_queue_len(dev, ifr->ifr_qlen);

case SIOCSIFNAME:
ifr->ifr_newname[IFNAMSIZ-1] = '\0';
Expand Down

0 comments on commit 8dd3020

Please sign in to comment.