From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by dpdk.org (Postfix) with ESMTP id 83A341E2B for ; Fri, 4 Nov 2016 18:36:32 +0100 (CET) Received: by mail-oi0-f50.google.com with SMTP id x4so172646489oix.2 for ; Fri, 04 Nov 2016 10:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NR/YdCxW1PJWhQlcqBbodDoLR7I59kG82mIGXtMSdLQ=; b=gjNUeaOCxrB9lYeW6GOGzBRfoztM4rHMEuaMvdK1dBjJsxX7M4qq+FdfQmWhcWX6V1 MkVO2KRneF25vOGCjKjfb0CVZe5bR0AcOr7J89sem0SgOZuAKw2YSPbfqNXFjT2GevqF d/9bMENzl+VNaFzXIVTAHrskjBrbyEg7uuNTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NR/YdCxW1PJWhQlcqBbodDoLR7I59kG82mIGXtMSdLQ=; b=I3wHQJzluFSnCPwuLmmnMTDjp2F0VjtgzR5Wxn9HcewSpgEfY6SPhftUlCq/AVV1h+ Z2ourn74XV0Y0fJ/d4YPNexDt7/qpD+VBVhKNyhoTxUQ0unXqzaguAobwbXSPIAdg2wi EGTmmnlFOS4/QT5lAwWXkcjgs6x0zvL74GoKTmh7TkjqW41QWkhyaffQR9gwfw6Iys99 4xxEBhMDOWrOzIEgmzCBpQFC84xYuXb1PkAGUYAahlHUg2QYhH0lc8u5t0MwIBpLKHH/ VFnsIFLMYJu7456/BWGV3k5QzAWGeY8qyqQoumSph1kMPpogAfmDZ5VqnEiNPMovgD71 YTEQ== X-Gm-Message-State: ABUngvdYNtO3uCfnnZngQBsyhfQUMDY/gri9n++dkwaEYqds/7ZUqK5N1JayX3bJw2/YEqicRsSPSM3R8CtrkJDB X-Received: by 10.107.165.146 with SMTP id o140mr13802332ioe.14.1478280991202; Fri, 04 Nov 2016 10:36:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.252.66 with HTTP; Fri, 4 Nov 2016 10:35:50 -0700 (PDT) In-Reply-To: References: <20161103185818.GA88405@C02PT1RBG8WP.wifi.aus.avagotech.net> From: Ajit Khaparde Date: Fri, 4 Nov 2016 12:35:50 -0500 Message-ID: To: Ferruh Yigit Cc: dev@dpdk.org, "John W. Linville" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [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: Fri, 04 Nov 2016 17:36:33 -0000 On Fri, Nov 4, 2016 at 5:52 AM, Ferruh Yigit wrote= : > On 11/3/2016 6:58 PM, Ajit Khaparde wrote: > > 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 =3D &bp->pf; > > @@ -197,7 +197,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) > > mz =3D rte_memzone_lookup(mz_name); > > if (!mz) { > > mz =3D 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 =3D > > - (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 =3D mz->phys_addr + (entry_lengt= h * > i); > > + vnic->rss_table_dma_addr =3D > > + mz->phys_addr + ((uint32_t) entry_length * i); > > ((uint32_t) entry_length * i) > casting entry_length to uint32_t will prevent the integer promotion and > fix the coverity issue, but if this is the case, why not make > entry_length uint32_t at first place? > > It seems "entry_length" converted from "int" to "uint16_t" to prevent > integer promotion (e8a197d2aa9a), but > "entry_length * max_vnics" =3D> "uint16_t * uint16_t" or > "entry_length * i" =3D> "uint16_t * int" > still causing the promotion. > > I guess converting "entry_length" to uint32_t (instead of uint16_t) will > fix both triaged 127557 and new introduced 137874 coverity issues, and > it is simpler modification, - if I don't miss anything J > =E2=80=8BSounds reasonable to me. I will send a patch in a little while. Thanks=E2=80=8B > > Thanks, > ferruh > > > > vnic->rss_hash_key =3D (void *)((char *)vnic->rss_table + > > HW_HASH_INDEX_SIZE * > sizeof(*vnic->rss_table)); > > > > > >