[dpdk-dev] eal: Fix wrong resource release of pci_uio_unmap()

Message ID 1465961221-28357-1-git-send-email-mukawa@igel.co.jp (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Tetsuya Mukawa June 15, 2016, 3:27 a.m. UTC
  The 'path' member of mapped_pci_resource structure is allocated by
primary process, but currenctly it will be freed by both primary
and secondary process.
The patch fixes to be freed by only primary process.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_eal/common/eal_common_pci_uio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

David Marchand June 15, 2016, 3:01 p.m. UTC | #1
On Wed, Jun 15, 2016 at 5:27 AM, Tetsuya Mukawa <mukawa@igel.co.jp> wrote:
> The 'path' member of mapped_pci_resource structure is allocated by
> primary process, but currenctly it will be freed by both primary
> and secondary process.
> The patch fixes to be freed by only primary process.
>
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>

Function name in title.

> ---
>  lib/librte_eal/common/eal_common_pci_uio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c
> index e718643..b2c68f3 100644
> --- a/lib/librte_eal/common/eal_common_pci_uio.c
> +++ b/lib/librte_eal/common/eal_common_pci_uio.c
> @@ -162,7 +162,9 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
>         for (i = 0; i != uio_res->nb_maps; i++) {
>                 pci_unmap_resource(uio_res->maps[i].addr,
>                                 (size_t)uio_res->maps[i].size);
> -               rte_free(uio_res->maps[i].path);
> +
> +               if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +                       rte_free(uio_res->maps[i].path);
>         }
>  }
>

The rest looks good to me.
  

Patch

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c
index e718643..b2c68f3 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -162,7 +162,9 @@  pci_uio_unmap(struct mapped_pci_resource *uio_res)
 	for (i = 0; i != uio_res->nb_maps; i++) {
 		pci_unmap_resource(uio_res->maps[i].addr,
 				(size_t)uio_res->maps[i].size);
-		rte_free(uio_res->maps[i].path);
+
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+			rte_free(uio_res->maps[i].path);
 	}
 }