From patchwork Fri Nov 25 09:09:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Baechle X-Patchwork-Id: 127670 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8C02D1007DA for ; Fri, 25 Nov 2011 22:09:57 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754571Ab1KYLJu (ORCPT ); Fri, 25 Nov 2011 06:09:50 -0500 Received: from h5.dl5rb.org.uk ([81.2.74.5]:52582 "EHLO linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754317Ab1KYLJt (ORCPT ); Fri, 25 Nov 2011 06:09:49 -0500 Received: from duck.linux-mips.net (duck.linux-mips.net [127.0.0.1]) by duck.linux-mips.net (8.14.4/8.14.4) with ESMTP id pAPB9Z7B022887; Fri, 25 Nov 2011 11:09:35 GMT Received: (from ralf@localhost) by duck.linux-mips.net (8.14.4/8.14.4/Submit) id pAPB9ZtU022886; Fri, 25 Nov 2011 11:09:35 GMT Message-Id: <9f87aed932fc551c6f5c474b39d01fb337237a7e.1322214950.git.ralf@linux-mips.org> In-Reply-To: References: From: Ralf Baechle Date: Fri, 25 Nov 2011 09:09:00 +0000 Subject: [PATCH 3/4] NET: NETROM: Cleanup argument SIOCADDRT ioctl argument checking. To: "David S. Miller" Cc: netdev@vger.kernel.org, linux-hams@vger.kernel.org, Thomas Osterried Lines: 32 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org nr_route.ndigis is unsigned int so the nr_route.ndigis < 0 expression is never true and can be dropped. Doing the nr_ax25_dev_get call later allows the nr_route.ndigis test to bail out without having to dev_put. Signed-off-by: Ralf Baechle Cc: Thomas Osterried --- net/netrom/nr_route.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index 8d7716c..2cf3301 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -670,12 +670,10 @@ int nr_rt_ioctl(unsigned int cmd, void __user *arg) case SIOCADDRT: if (copy_from_user(&nr_route, arg, sizeof(struct nr_route_struct))) return -EFAULT; - if ((dev = nr_ax25_dev_get(nr_route.device)) == NULL) + if (nr_route.ndigis > AX25_MAX_DIGIS) return -EINVAL; - if (nr_route.ndigis < 0 || nr_route.ndigis > AX25_MAX_DIGIS) { - dev_put(dev); + if ((dev = nr_ax25_dev_get(nr_route.device)) == NULL) return -EINVAL; - } switch (nr_route.type) { case NETROM_NODE: if (strnlen(nr_route.mnemonic, 7) == 7) {