From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by dpdk.org (Postfix) with ESMTP id 68D882952 for ; Thu, 3 Nov 2016 19:58:22 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.31,587,1473145200"; d="scan'208";a="110242572" Received: from mail-irv-17.broadcom.com ([10.15.198.34]) by mail-gw2-out.broadcom.com with ESMTP; 03 Nov 2016 12:39:28 -0700 Received: from C02PT1RBG8WP.wifi.aus.avagotech.net (c02pt1rbg8wp.wifi.aus.avagotech.net [10.10.168.137]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 0592C82028 for ; Thu, 3 Nov 2016 11:58:20 -0700 (PDT) Date: Thu, 3 Nov 2016 13:58:18 -0500 From: Ajit Khaparde To: dev@dpdk.org Message-ID: <20161103185818.GA88405@C02PT1RBG8WP.wifi.aus.avagotech.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [dpdk-dev] [PATCH 1/2 v2] bnxt: use appropriate data type in bnxt_alloc_vnic_attributes 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: Thu, 03 Nov 2016 18:58:22 -0000 Prevent the arithmetic in bnxt_alloc_vnic_attributes from causing any unintentional havoc because of the usage of a signed variable. Coverity: 137874 Signed-off-by: Ajit Khaparde -- v2: Previous attempt did not seem complete. --- drivers/net/bnxt/bnxt_vnic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index 205a940..23c85af 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -179,7 +179,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) HW_HASH_INDEX_SIZE * sizeof(*vnic->rss_table) + HW_HASH_KEY_SIZE); uint16_t max_vnics; - int i; + uint16_t i; if (BNXT_PF(bp)) { struct bnxt_pf_info *pf = &bp->pf; @@ -197,7 +197,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) mz = rte_memzone_lookup(mz_name); if (!mz) { mz = rte_memzone_reserve(mz_name, - entry_length * max_vnics, + (uint32_t) entry_length * max_vnics, SOCKET_ID_ANY, RTE_MEMZONE_2MB | RTE_MEMZONE_SIZE_HINT_ONLY); @@ -210,10 +210,11 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) /* Allocate rss table and hash key */ vnic->rss_table = - (void *)((char *)mz->addr + (entry_length * i)); + (void *)((char *)mz->addr + ((uint32_t) entry_length * i)); memset(vnic->rss_table, -1, entry_length); - vnic->rss_table_dma_addr = mz->phys_addr + (entry_length * i); + vnic->rss_table_dma_addr = + mz->phys_addr + ((uint32_t) entry_length * i); vnic->rss_hash_key = (void *)((char *)vnic->rss_table + HW_HASH_INDEX_SIZE * sizeof(*vnic->rss_table)); -- 1.8.3.1