[dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug

Burakov, Anatoly anatoly.burakov at intel.com
Fri Oct 26 16:22:18 CEST 2018


On 25-Oct-18 11:46 AM, Darek Stojaczyk wrote:
> rte_mp_request_sync() says that the caller is responsible
> for freeing one of its parameters afterwards. EAL didn't
> do that, causing a memory leak.
> 
> Fixes: 244d5130719c ("eal: enable hotplug on multi-process")
> Cc: qi.z.zhang at intel.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk at intel.com>
> ---
>   lib/librte_eal/common/hotplug_mp.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c
> index 84f59d95b..9a6a88546 100644
> --- a/lib/librte_eal/common/hotplug_mp.c
> +++ b/lib/librte_eal/common/hotplug_mp.c
> @@ -355,6 +355,7 @@ int eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req)
>   	resp = (struct eal_dev_mp_req *)mp_reply.msgs[0].param;
>   	req->result = resp->result;
>   
> +	free(mp_reply.msgs);
>   	return ret;
>   }
>   
> @@ -397,6 +398,7 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
>   		}
>   	}
>   
> +	free(mp_reply.msgs);
>   	return 0;
>   }
>   
> 

This is correct but incomplete. There are also numerous error conditions 
which check for number of received responses to be a particular number, 
and if the number don't match, we just exit without freeing memory. 
Those errors need to free the memory as well.

-- 
Thanks,
Anatoly


More information about the dev mailing list