From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alejandro Lucero Subject: Re: [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range Date: Wed, 9 May 2018 10:54:52 +0100 Message-ID: References: <152582834896.6809.14521072557832633661.stgit@localhost.localdomain> <152582948593.6809.11000716617448256936.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Cc: dev To: Andy Green Return-path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 4E77BAABC for ; Wed, 9 May 2018 11:54:53 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id l1-v6so26610600wmb.2 for ; Wed, 09 May 2018 02:54:53 -0700 (PDT) In-Reply-To: <152582948593.6809.11000716617448256936.stgit@localhost.localdomain> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, May 9, 2018 at 2:31 AM, Andy Green wrote: > /home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:669:2: > error: =E2=80=98memcpy=E2=80=99 forming offset [5, 6] is out of the bound= s > [0, 4] of object =E2=80=98tmp=E2=80=99 with type =E2=80=98uint32_t=E2=80= =99 {aka =E2=80=98unsigned > int=E2=80=99} [-Werror=3Darray-bounds] memcpy(&hw->mac_addr[0], > &tmp, sizeof(struct ether_addr)); > > Signed-off-by: Andy Green > --- > drivers/net/nfp/nfp_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c > index 048324ec9..199aac40b 100644 > --- a/drivers/net/nfp/nfp_net.c > +++ b/drivers/net/nfp/nfp_net.c > @@ -666,7 +666,7 @@ nfp_net_vf_read_mac(struct nfp_net_hw *hw) > uint32_t tmp; > > tmp =3D rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR)); > - memcpy(&hw->mac_addr[0], &tmp, sizeof(struct ether_addr)); > + memcpy(&hw->mac_addr[0], &tmp, 4); > > tmp =3D rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4= )); > memcpy(&hw->mac_addr[4], &tmp, 2); > > Acked-by: Alejandro Lucero Tested-by: Alejandro Lucero