From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id DA9CE37B1 for ; Mon, 19 Sep 2016 19:06:37 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 19 Sep 2016 10:06:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,362,1470726000"; d="scan'208";a="763370082" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.115]) ([10.237.220.115]) by FMSMGA003.fm.intel.com with ESMTP; 19 Sep 2016 10:06:36 -0700 From: Ferruh Yigit To: Xiao Wang , wenzhuo.lu@intel.com References: <1472312902-16963-1-git-send-email-xiao.w.wang@intel.com> <1472312902-16963-24-git-send-email-xiao.w.wang@intel.com> Cc: dev@dpdk.org Message-ID: <6968dbf3-b814-b70f-26d9-0daf3d1d0126@intel.com> Date: Mon, 19 Sep 2016 18:06:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1472312902-16963-24-git-send-email-xiao.w.wang@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 23/39] net/ixgbe/base: add bound check in LED functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 17:06:38 -0000 On 8/27/2016 4:48 PM, Xiao Wang wrote: > Do parameter check to prevent exceptional value being written into > register. > > Signed-off-by: Xiao Wang > --- > drivers/net/ixgbe/base/ixgbe_common.c | 15 ++++++++++++++- > drivers/net/ixgbe/base/ixgbe_x540.c | 6 ++++++ > 2 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ixgbe/base/ixgbe_common.c b/drivers/net/ixgbe/base/ixgbe_common.c > index 1c7263d..3c3272e 100644 > --- a/drivers/net/ixgbe/base/ixgbe_common.c > +++ b/drivers/net/ixgbe/base/ixgbe_common.c > @@ -1133,6 +1133,9 @@ s32 ixgbe_led_on_generic(struct ixgbe_hw *hw, u32 index) > > DEBUGFUNC("ixgbe_led_on_generic"); > > + if (index > 3) What about using macro for hardcoded value 3. > + return IXGBE_ERR_PARAM; > + > /* To turn on the LED, set mode to ON. */ > led_reg &= ~IXGBE_LED_MODE_MASK(index); > led_reg |= IXGBE_LED_ON << IXGBE_LED_MODE_SHIFT(index); > @@ -1153,6 +1156,9 @@ s32 ixgbe_led_off_generic(struct ixgbe_hw *hw, u32 index) > > DEBUGFUNC("ixgbe_led_off_generic"); > > + if (index > 3) > + return IXGBE_ERR_PARAM; > + > /* To turn off the LED, set mode to OFF. */ > led_reg &= ~IXGBE_LED_MODE_MASK(index); > led_reg |= IXGBE_LED_OFF << IXGBE_LED_MODE_SHIFT(index); > @@ -3341,7 +3347,7 @@ s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked) > **/ > s32 ixgbe_enable_sec_rx_path_generic(struct ixgbe_hw *hw) > { > - int secrxreg; > + u32 secrxreg; This modification seems unrelated with the patch. >