From patchwork Fri Mar 1 05:20:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 2200351 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id F1A5B3FCA4 for ; Fri, 1 Mar 2013 05:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001Ab3CAFWO (ORCPT ); Fri, 1 Mar 2013 00:22:14 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:31102 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884Ab3CAFWM (ORCPT ); Fri, 1 Mar 2013 00:22:12 -0500 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r215LfiK025369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Mar 2013 05:21:42 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r215LdUG000911 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Mar 2013 05:21:39 GMT Received: from abhmt112.oracle.com (abhmt112.oracle.com [141.146.116.64]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r215LcxY002682; Thu, 28 Feb 2013 23:21:38 -0600 Received: from longonot.mountain (/41.202.233.188) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 Feb 2013 21:21:37 -0800 Date: Fri, 1 Mar 2013 08:20:21 +0300 From: Dan Carpenter To: Lauro Ramos Venancio Cc: Aloisio Almeida Jr , Samuel Ortiz , "David S. Miller" , "John W. Linville" , Thierry Escande , Szymon Janc , linux-wireless@vger.kernel.org, linux-nfc@ml01.01.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] NFC: llcp: cleanup underflow check Message-ID: <20130301052021.GB2669@longonot.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2148581.S8tzak9aE2@uw000953> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Szymon Janc suggested I should move the lower bound check into the caller and make it match the check for NFC_MAX_GT_LEN. Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 87a6417..e50dd2c 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -74,6 +74,7 @@ struct nfc_ops { #define NFC_TARGET_IDX_ANY -1 #define NFC_MAX_GT_LEN 48 +#define NFC_MIN_GT_LEN 3 #define NFC_ATR_RES_GT_OFFSET 15 struct nfc_target { diff --git a/net/nfc/core.c b/net/nfc/core.c index 6ceee8e..e2c3b6e 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -450,7 +450,7 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) { pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len); - if (gb_len > NFC_MAX_GT_LEN) + if (gb_len < NFC_MIN_GT_LEN || gb_len > NFC_MAX_GT_LEN) return -EINVAL; return nfc_llcp_set_remote_gb(dev, gb, gb_len); diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 7f8266d..7be27fb 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c @@ -547,8 +547,6 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) pr_err("No LLCP device\n"); return -ENODEV; } - if (gb_len < 3) - return -EINVAL; memset(local->remote_gb, 0, NFC_MAX_GT_LEN); memcpy(local->remote_gb, gb, gb_len);