From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tariq Toukan Subject: [PATCH net-next v2] net: remove redundant input checks in SIOCSIFTXQLEN case of dev_ifsioc Date: Tue, 24 Jul 2018 13:53:00 +0300 Message-ID: <1532429580-9710-1-git-send-email-tariqt@mellanox.com> Cc: netdev@vger.kernel.org, Eran Ben Elisha , Tariq Toukan , Cong Wang To: "David S. Miller" Return-path: Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:55013 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388308AbeGXL7D (ORCPT ); Tue, 24 Jul 2018 07:59:03 -0400 Sender: netdev-owner@vger.kernel.org List-ID: 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: 3f76df198288 ("net: use dev_change_tx_queue_len() for SIOCSIFTXQLEN") Signed-off-by: Tariq Toukan Reviewed-by: Eran Ben Elisha Cc: Cong Wang --- net/core/dev_ioctl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) v1 -> v2: * Retained negative value check, per comments from Cong and Dave. * Updated commit message accordingly. diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 50537ff961a7..90e8aa36881e 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -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'; -- 1.8.3.1