DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug
@ 2018-10-25 10:46 Darek Stojaczyk
  2018-10-26 14:22 ` Burakov, Anatoly
  2018-10-29 11:47 ` [dpdk-dev] [PATCH v2] eal: fix IPC " Darek Stojaczyk
  0 siblings, 2 replies; 7+ messages in thread
From: Darek Stojaczyk @ 2018-10-25 10:46 UTC (permalink / raw)
  To: dev; +Cc: Darek Stojaczyk, qi.z.zhang, stable

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@intel.com
Cc: stable@dpdk.org

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@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;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug
  2018-10-25 10:46 [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug Darek Stojaczyk
@ 2018-10-26 14:22 ` Burakov, Anatoly
  2018-10-29 12:02   ` Stojaczyk, Dariusz
  2018-10-29 11:47 ` [dpdk-dev] [PATCH v2] eal: fix IPC " Darek Stojaczyk
  1 sibling, 1 reply; 7+ messages in thread
From: Burakov, Anatoly @ 2018-10-26 14:22 UTC (permalink / raw)
  To: Darek Stojaczyk, dev; +Cc: qi.z.zhang, stable

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@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v2] eal: fix IPC memleak on device hotplug
  2018-10-25 10:46 [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug Darek Stojaczyk
  2018-10-26 14:22 ` Burakov, Anatoly
@ 2018-10-29 11:47 ` Darek Stojaczyk
  2018-10-30 10:15   ` Burakov, Anatoly
  1 sibling, 1 reply; 7+ messages in thread
From: Darek Stojaczyk @ 2018-10-29 11:47 UTC (permalink / raw)
  To: dev; +Cc: Darek Stojaczyk, qi.z.zhang, anatoly.burakov

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@intel.com
Cc: anatoly.burakov@intel.com

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
 lib/librte_eal/common/hotplug_mp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c
index 84f59d95b..b68e4cabb 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;
 }
 
@@ -379,6 +380,7 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
 
 	if (mp_reply.nb_sent != mp_reply.nb_received) {
 		RTE_LOG(ERR, EAL, "not all secondary reply\n");
+		free(mp_reply.msgs);
 		return -1;
 	}
 
@@ -397,6 +399,7 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req)
 		}
 	}
 
+	free(mp_reply.msgs);
 	return 0;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug
  2018-10-26 14:22 ` Burakov, Anatoly
@ 2018-10-29 12:02   ` Stojaczyk, Dariusz
  2018-10-29 14:25     ` Zhang, Qi Z
  0 siblings, 1 reply; 7+ messages in thread
From: Stojaczyk, Dariusz @ 2018-10-29 12:02 UTC (permalink / raw)
  To: Burakov, Anatoly, dev; +Cc: Zhang, Qi Z, stable

> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Friday, October 26, 2018 4:22 PM
> To: Stojaczyk, Dariusz <dariusz.stojaczyk@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak
> on device hotplug
> 
> <SNIP>
>
> 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.
> 

Yup, thanks. I pushed v2 with one extra free() in the function notifying secondary processes.
The function which notifies the primary process has a similar error check -
 - `if (mp_reply.nb_received == 1)`  - but I figured if there's more than 1 primary process
replying, then the memory leak is your smallest problem.

> --
> Thanks,
> Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug
  2018-10-29 12:02   ` Stojaczyk, Dariusz
@ 2018-10-29 14:25     ` Zhang, Qi Z
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Qi Z @ 2018-10-29 14:25 UTC (permalink / raw)
  To: Stojaczyk, Dariusz, Burakov, Anatoly, dev; +Cc: stable



> -----Original Message-----
> From: Stojaczyk, Dariusz
> Sent: Monday, October 29, 2018 7:02 AM
> To: Burakov, Anatoly <anatoly.burakov@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on
> device hotplug
> 
> > -----Original Message-----
> > From: Burakov, Anatoly
> > Sent: Friday, October 26, 2018 4:22 PM
> > To: Stojaczyk, Dariusz <dariusz.stojaczyk@intel.com>; dev@dpdk.org
> > Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak
> > on device hotplug
> >
> > <SNIP>
> >
> > 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.
> >
> 
> Yup, thanks. I pushed v2 with one extra free() in the function notifying
> secondary processes.
> The function which notifies the primary process has a similar error check -
>  - `if (mp_reply.nb_received == 1)`  - but I figured if there's more than 1
> primary process replying, then the memory leak is your smallest problem.


Good capture!
Thanks for fix this.

> 
> > --
> > Thanks,
> > Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal: fix IPC memleak on device hotplug
  2018-10-29 11:47 ` [dpdk-dev] [PATCH v2] eal: fix IPC " Darek Stojaczyk
@ 2018-10-30 10:15   ` Burakov, Anatoly
  2018-10-31 17:21     ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: Burakov, Anatoly @ 2018-10-30 10:15 UTC (permalink / raw)
  To: Darek Stojaczyk, dev; +Cc: qi.z.zhang

On 29-Oct-18 11:47 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@intel.com
> Cc: anatoly.burakov@intel.com
> 
> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal: fix IPC memleak on device hotplug
  2018-10-30 10:15   ` Burakov, Anatoly
@ 2018-10-31 17:21     ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2018-10-31 17:21 UTC (permalink / raw)
  To: Darek Stojaczyk; +Cc: dev, Burakov, Anatoly, qi.z.zhang

30/10/2018 11:15, Burakov, Anatoly:
> On 29-Oct-18 11:47 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@intel.com
> > Cc: anatoly.burakov@intel.com
> > 
> > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-31 17:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 10:46 [dpdk-dev] [PATCH] eal: fix rte_mp_request_sync() memleak on device hotplug Darek Stojaczyk
2018-10-26 14:22 ` Burakov, Anatoly
2018-10-29 12:02   ` Stojaczyk, Dariusz
2018-10-29 14:25     ` Zhang, Qi Z
2018-10-29 11:47 ` [dpdk-dev] [PATCH v2] eal: fix IPC " Darek Stojaczyk
2018-10-30 10:15   ` Burakov, Anatoly
2018-10-31 17:21     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).