[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-16 Thread Tetsuya Mukawa
On 2016/06/15 23:45, David Marchand wrote:
> Hello Tetsuya,
> 
> On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
>> If pci_map_resource() succeeds but mapped address is different from an
>> address primary process mapped, this should be error.
>> Then the address secondary process mapped should be freed.
>>
>> Signed-off-by: Tetsuya Mukawa 
> 
> The title should not contain the function name.

Hi David,

Thanks, I will change the title of all patches.

> 
> 
>> ---
>>  lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
>> b/lib/librte_eal/common/eal_common_pci_uio.c
>> index f062e81..e718643 100644
>> --- a/lib/librte_eal/common/eal_common_pci_uio.c
>> +++ b/lib/librte_eal/common/eal_common_pci_uio.c
>> @@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
>> "Cannot mmap device resource file %s 
>> to address: %p\n",
>> uio_res->maps[i].path,
>> uio_res->maps[i].addr);
>> +   if (mapaddr != MAP_FAILED)
>> +   pci_unmap_resource(mapaddr,
>> +   
>> (size_t)uio_res->maps[i].size);
>> return -1;
>> }
>> }
> 
> What of the previous mappings that might have succeeded earlier in this loop ?

I will unmap all addresses mapped before.

Thanks,
Tetsuya


[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-15 Thread David Marchand
Hello Tetsuya,

On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
> If pci_map_resource() succeeds but mapped address is different from an
> address primary process mapped, this should be error.
> Then the address secondary process mapped should be freed.
>
> Signed-off-by: Tetsuya Mukawa 

The title should not contain the function name.


> ---
>  lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
> b/lib/librte_eal/common/eal_common_pci_uio.c
> index f062e81..e718643 100644
> --- a/lib/librte_eal/common/eal_common_pci_uio.c
> +++ b/lib/librte_eal/common/eal_common_pci_uio.c
> @@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
> "Cannot mmap device resource file %s 
> to address: %p\n",
> uio_res->maps[i].path,
> uio_res->maps[i].addr);
> +   if (mapaddr != MAP_FAILED)
> +   pci_unmap_resource(mapaddr,
> +   
> (size_t)uio_res->maps[i].size);
> return -1;
> }
> }

What of the previous mappings that might have succeeded earlier in this loop ?


-- 
David Marchand


[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-15 Thread Tetsuya Mukawa
If pci_map_resource() succeeds but mapped address is different from an
address primary process mapped, this should be error.
Then the address secondary process mapped should be freed.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index f062e81..e718643 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to 
address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
+   if (mapaddr != MAP_FAILED)
+   pci_unmap_resource(mapaddr,
+   (size_t)uio_res->maps[i].size);
return -1;
}
}
-- 
2.7.4