From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Pattan, Reshma" Subject: Re: [PATCH v4 1/2] librte_ether: add protection against overwrite device data Date: Wed, 28 Sep 2016 14:03:54 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831F010A91F9@IRSMSX109.ger.corp.intel.com> References: <1474901586-8706-2-git-send-email-marcinx.kerlin@intel.com> <1474974783-4861-1-git-send-email-marcinx.kerlin@intel.com> <1474974783-4861-2-git-send-email-marcinx.kerlin@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "De Lara Guarch, Pablo" , "thomas.monjalon@6wind.com" , "Kerlin, MarcinX" To: "Kerlin, MarcinX" , "dev@dpdk.org" Return-path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id A664E374F for ; Wed, 28 Sep 2016 16:03:58 +0200 (CEST) In-Reply-To: <1474974783-4861-2-git-send-email-marcinx.kerlin@intel.com> Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marcin Kerlin > Sent: Tuesday, September 27, 2016 12:13 PM > To: dev@dpdk.org > Cc: De Lara Guarch, Pablo ; > thomas.monjalon@6wind.com; Kerlin, MarcinX > Subject: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against > overwrite device data >=20 > +int > +rte_eth_dev_release_dev_data(uint8_t port_id) { > + char device[RTE_ETH_NAME_MAX_LEN]; > + struct rte_eth_dev_data *eth_dev_data =3D NULL; > + > + > @@ -631,6 +691,8 @@ int > rte_eth_dev_detach(uint8_t port_id, char *name) { > struct rte_pci_addr addr; > + struct rte_eth_dev_data *eth_dev_data =3D NULL; > + char device[RTE_ETH_NAME_MAX_LEN]; > int ret =3D -1; >=20 > if (name =3D=3D NULL) { > @@ -642,6 +704,15 @@ rte_eth_dev_detach(uint8_t port_id, char *name) > if (rte_eth_dev_is_detachable(port_id)) > goto err; >=20 > + /* get device name by port id */ > + if (rte_eth_dev_get_name_by_port(port_id, device)) > + goto err; > + > + /* look for an entry in the shared device data */ > + eth_dev_data =3D rte_eth_dev_get_dev_data_by_name(device); > + if (eth_dev_data =3D=3D NULL) > + goto err; > + > if (rte_eth_dev_get_device_type(port_id) =3D=3D RTE_ETH_DEV_PCI) { > ret =3D rte_eth_dev_get_addr_by_port(port_id, &addr); > if (ret < 0) > @@ -661,6 +732,9 @@ rte_eth_dev_detach(uint8_t port_id, char *name) > goto err; > } >=20 > + /* clear an entry in the shared device data */ > + memset(eth_dev_data, 0, sizeof(struct rte_eth_dev_data)); > + > return 0; >=20 In this function, the new code chunks together is nothing but the function= " rte_eth_dev_release_dev_data()". So u can call the function itself rather than a duplicate code. =20 Thanks, Reshma