patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb
       [not found] <cover.1593768308.git.wangyunjian@huawei.com>
@ 2020-07-03  9:46 ` wangyunjian
  2020-07-29 11:47   ` wangyunjian
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 2/3] eal: return error code when failure wangyunjian
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists wangyunjian
  2 siblings, 1 reply; 5+ messages in thread
From: wangyunjian @ 2020-07-03  9:46 UTC (permalink / raw)
  To: dev; +Cc: jia.guo, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The event_cb->dev_name is not freed when freeing event_cb,
and this causes a memory leak.

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 9e4f09d..363a2ca 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 		 */
 		if (event_cb->active == 0) {
 			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
+			free(event_cb->dev_name);
 			free(event_cb);
 			ret++;
 		} else {
-- 
1.8.3.1



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

* [dpdk-stable] [dpdk-dev] [PATCH v4 2/3] eal: return error code when failure
       [not found] <cover.1593768308.git.wangyunjian@huawei.com>
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb wangyunjian
@ 2020-07-03  9:46 ` wangyunjian
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists wangyunjian
  2 siblings, 0 replies; 5+ messages in thread
From: wangyunjian @ 2020-07-03  9:46 UTC (permalink / raw)
  To: dev; +Cc: jia.guo, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Fix return value, using -EAGAIN instead of 0 when the callback is busy
and using -ENOENT instead of 0 when the callback is not found.

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org

Acked-by: Jeff Guo <jia.guo@intel.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 363a2ca..d990bfd 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -530,9 +530,15 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 			free(event_cb);
 			ret++;
 		} else {
-			continue;
+			ret = -EAGAIN;
+			break;
 		}
 	}
+
+	/* this callback is not be registered */
+	if (ret == 0)
+		ret = -ENOENT;
+
 	rte_spinlock_unlock(&dev_event_lock);
 	return ret;
 }
-- 
1.8.3.1



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

* [dpdk-stable] [dpdk-dev] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists
       [not found] <cover.1593768308.git.wangyunjian@huawei.com>
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb wangyunjian
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 2/3] eal: return error code when failure wangyunjian
@ 2020-07-03  9:46 ` wangyunjian
  2 siblings, 0 replies; 5+ messages in thread
From: wangyunjian @ 2020-07-03  9:46 UTC (permalink / raw)
  To: dev; +Cc: jia.guo, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

We should return an error value, when the callback is already exist.

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index d990bfd..2a097aa 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -431,7 +431,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 				void *cb_arg)
 {
 	struct dev_event_callback *event_cb;
-	int ret;
+	int ret = 0;
 
 	if (!cb_fn)
 		return -EINVAL;
@@ -484,7 +484,7 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 	}
 
 	rte_spinlock_unlock(&dev_event_lock);
-	return 0;
+	return ret;
 error:
 	free(event_cb);
 	rte_spinlock_unlock(&dev_event_lock);
-- 
1.8.3.1



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb
  2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb wangyunjian
@ 2020-07-29 11:47   ` wangyunjian
  2020-07-30  2:57     ` Jeff Guo
  0 siblings, 1 reply; 5+ messages in thread
From: wangyunjian @ 2020-07-29 11:47 UTC (permalink / raw)
  To: dev; +Cc: jia.guo, Lilijun (Jerry), xudingke, stable

Ping for review.

Thanks,
Yunjian

> -----Original Message-----
> From: wangyunjian
> Sent: Friday, July 3, 2020 5:46 PM
> To: dev@dpdk.org
> Cc: jia.guo@intel.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; wangyunjian <wangyunjian@huawei.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing
> event_cb
> 
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The event_cb->dev_name is not freed when freeing event_cb, and this causes a
> memory leak.
> 
> Fixes: a753e53d517b ("eal: add device event monitor framework")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  lib/librte_eal/common/eal_common_dev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_eal/common/eal_common_dev.c
> b/lib/librte_eal/common/eal_common_dev.c
> index 9e4f09d..363a2ca 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev,
> const void *_name)
>  		 */
>  		if (event_cb->active == 0) {
>  			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
> +			free(event_cb->dev_name);
>  			free(event_cb);
>  			ret++;
>  		} else {
> --
> 1.8.3.1
> 


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb
  2020-07-29 11:47   ` wangyunjian
@ 2020-07-30  2:57     ` Jeff Guo
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Guo @ 2020-07-30  2:57 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: Lilijun (Jerry), xudingke, stable

hi, yunjian

The patch seems no problem, but when you update your patch, please add 
other guys who had comment on your patch and maintainer to see if they have

other opinion, and --in-reply-to is also helpful for patch review, thanks.

On 7/29/2020 7:47 PM, wangyunjian wrote:
> Ping for review.
>
> Thanks,
> Yunjian
>
>> -----Original Message-----
>> From: wangyunjian
>> Sent: Friday, July 3, 2020 5:46 PM
>> To: dev@dpdk.org
>> Cc: jia.guo@intel.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
>> <xudingke@huawei.com>; wangyunjian <wangyunjian@huawei.com>;
>> stable@dpdk.org
>> Subject: [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing
>> event_cb
>>
>> From: Yunjian Wang <wangyunjian@huawei.com>
>>
>> The event_cb->dev_name is not freed when freeing event_cb, and this causes a
>> memory leak.
>>
>> Fixes: a753e53d517b ("eal: add device event monitor framework")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>> ---
>>   lib/librte_eal/common/eal_common_dev.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/librte_eal/common/eal_common_dev.c
>> b/lib/librte_eal/common/eal_common_dev.c
>> index 9e4f09d..363a2ca 100644
>> --- a/lib/librte_eal/common/eal_common_dev.c
>> +++ b/lib/librte_eal/common/eal_common_dev.c
>> @@ -526,6 +526,7 @@ static int cmp_dev_name(const struct rte_device *dev,
>> const void *_name)
>>   		 */
>>   		if (event_cb->active == 0) {
>>   			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
>> +			free(event_cb->dev_name);
>>   			free(event_cb);
>>   			ret++;
>>   		} else {
>> --
>> 1.8.3.1


Acked-by: Jeff Guo <jia.guo@intel.com>


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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1593768308.git.wangyunjian@huawei.com>
2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 1/3] eal: fix memory leak when removing event_cb wangyunjian
2020-07-29 11:47   ` wangyunjian
2020-07-30  2:57     ` Jeff Guo
2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 2/3] eal: return error code when failure wangyunjian
2020-07-03  9:46 ` [dpdk-stable] [dpdk-dev] [PATCH v4 3/3] eal: fix a wrong returned value when callback exists wangyunjian

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox