patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH v5 1/3] eal: fix memory leak when removing event_cb
       [not found] <cover.1603207676.git.wangyunjian@huawei.com>
@ 2020-10-21 11:19 ` wangyunjian
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure wangyunjian
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists wangyunjian
  2 siblings, 0 replies; 7+ messages in thread
From: wangyunjian @ 2020-10-21 11:19 UTC (permalink / raw)
  To: dev
  Cc: david.marchand, jia.guo, jerinj, 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>
Acked-by: Jeff Guo <jia.guo@intel.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 9e4f09d83e..363a2ca95e 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -526,6 +526,7 @@ rte_dev_event_callback_unregister(const char *device_name,
 		 */
 		if (event_cb->active == 0) {
 			TAILQ_REMOVE(&dev_event_cbs, event_cb, next);
+			free(event_cb->dev_name);
 			free(event_cb);
 			ret++;
 		} else {
-- 
2.23.0


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

* [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
       [not found] <cover.1603207676.git.wangyunjian@huawei.com>
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 1/3] eal: fix memory leak when removing event_cb wangyunjian
@ 2020-10-21 11:19 ` wangyunjian
  2020-10-22 12:51   ` David Marchand
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists wangyunjian
  2 siblings, 1 reply; 7+ messages in thread
From: wangyunjian @ 2020-10-21 11:19 UTC (permalink / raw)
  To: dev
  Cc: david.marchand, jia.guo, jerinj, 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

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Jeff Guo <jia.guo@intel.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 363a2ca95e..d990bfd20d 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_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;
 }
-- 
2.23.0


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

* [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists
       [not found] <cover.1603207676.git.wangyunjian@huawei.com>
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 1/3] eal: fix memory leak when removing event_cb wangyunjian
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure wangyunjian
@ 2020-10-21 11:19 ` wangyunjian
  2020-10-22 12:55   ` David Marchand
  2 siblings, 1 reply; 7+ messages in thread
From: wangyunjian @ 2020-10-21 11:19 UTC (permalink / raw)
  To: dev
  Cc: david.marchand, jia.guo, jerinj, 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>
Suggested-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/common/eal_common_dev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index d990bfd20d..8a3bd3100a 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -480,7 +480,9 @@ rte_dev_event_callback_register(const char *device_name,
 		RTE_LOG(ERR, EAL,
 			"The callback is already exist, no need "
 			"to register again.\n");
+		event_cb = NULL;
 		ret = -EEXIST;
+		goto error;
 	}
 
 	rte_spinlock_unlock(&dev_event_lock);
-- 
2.23.0


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure wangyunjian
@ 2020-10-22 12:51   ` David Marchand
  2020-10-23  9:05     ` wangyunjian
  0 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2020-10-22 12:51 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, Jeff Guo, Jerin Jacob Kollanukkaran, Lilijun (Jerry),
	xudingke, dpdk stable, Kevin Traynor, Luca Boccassi

On Wed, Oct 21, 2020 at 1:19 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> 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

This API is experimental, its description is vague enough and we can
change it in the current release.
But I see this as a change in behavior for existing users, not a fix
and I would not backport it.

Opinions?


>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Acked-by: Jeff Guo <jia.guo@intel.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 363a2ca95e..d990bfd20d 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_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;
>  }
> --
> 2.23.0
>


-- 
David Marchand


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists
  2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists wangyunjian
@ 2020-10-22 12:55   ` David Marchand
  2020-10-23  9:05     ` wangyunjian
  0 siblings, 1 reply; 7+ messages in thread
From: David Marchand @ 2020-10-22 12:55 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, Jeff Guo, Jerin Jacob Kollanukkaran, Lilijun (Jerry),
	xudingke, dpdk stable, Kevin Traynor, Luca Boccassi

On Wed, Oct 21, 2020 at 1:20 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> 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

Same question as for the previous patch, should we backport this?


-- 
David Marchand


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
  2020-10-22 12:51   ` David Marchand
@ 2020-10-23  9:05     ` wangyunjian
  0 siblings, 0 replies; 7+ messages in thread
From: wangyunjian @ 2020-10-23  9:05 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Jeff Guo, Jerin Jacob Kollanukkaran, Lilijun (Jerry),
	xudingke, dpdk stable, Kevin Traynor, Luca Boccassi

> -----Original Message-----
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Thursday, October 22, 2020 8:52 PM
> To: wangyunjian <wangyunjian@huawei.com>
> Cc: dev <dev@dpdk.org>; Jeff Guo <jia.guo@intel.com>; Jerin Jacob
> Kollanukkaran <jerinj@marvell.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>;
> xudingke <xudingke@huawei.com>; dpdk stable <stable@dpdk.org>; Kevin
> Traynor <ktraynor@redhat.com>; Luca Boccassi <bluca@debian.org>
> Subject: Re: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure
> 
> On Wed, Oct 21, 2020 at 1:19 PM wangyunjian <wangyunjian@huawei.com>
> wrote:
> >
> > 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
> 
> This API is experimental, its description is vague enough and we can change it
> in the current release.
> But I see this as a change in behavior for existing users, not a fix and I would
> not backport it.
> 
> Opinions?

Agree, not backport it.

Yunjian

> 
> 
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > Acked-by: Jeff Guo <jia.guo@intel.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 363a2ca95e..d990bfd20d 100644
> > --- a/lib/librte_eal/common/eal_common_dev.c
> > +++ b/lib/librte_eal/common/eal_common_dev.c
> > @@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char
> *device_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;
> >  }
> > --
> > 2.23.0
> >
> 
> 
> --
> David Marchand


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists
  2020-10-22 12:55   ` David Marchand
@ 2020-10-23  9:05     ` wangyunjian
  0 siblings, 0 replies; 7+ messages in thread
From: wangyunjian @ 2020-10-23  9:05 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Jeff Guo, Jerin Jacob Kollanukkaran, Lilijun (Jerry),
	xudingke, dpdk stable, Kevin Traynor, Luca Boccassi

> -----Original Message-----
> From: David Marchand [mailto:david.marchand@redhat.com]
> Sent: Thursday, October 22, 2020 8:55 PM
> To: wangyunjian <wangyunjian@huawei.com>
> Cc: dev <dev@dpdk.org>; Jeff Guo <jia.guo@intel.com>; Jerin Jacob
> Kollanukkaran <jerinj@marvell.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>;
> xudingke <xudingke@huawei.com>; dpdk stable <stable@dpdk.org>; Kevin
> Traynor <ktraynor@redhat.com>; Luca Boccassi <bluca@debian.org>
> Subject: Re: [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when
> callback exists
> 
> On Wed, Oct 21, 2020 at 1:20 PM wangyunjian <wangyunjian@huawei.com>
> wrote:
> >
> > 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
> 
> Same question as for the previous patch, should we backport this?

Agree, not backport it.

Yunjian

> 
> 
> --
> David Marchand


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

end of thread, other threads:[~2020-10-23  9:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1603207676.git.wangyunjian@huawei.com>
2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 1/3] eal: fix memory leak when removing event_cb wangyunjian
2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure wangyunjian
2020-10-22 12:51   ` David Marchand
2020-10-23  9:05     ` wangyunjian
2020-10-21 11:19 ` [dpdk-stable] [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists wangyunjian
2020-10-22 12:55   ` David Marchand
2020-10-23  9:05     ` wangyunjian

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).