[v5,3/3] eal: fix a wrong returned value when callback exists

Message ID 7ec6b12bf0f9fcdb2306dec72390a853abdf2f56.1603207676.git.wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series fixes for device event |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Yunjian Wang Oct. 21, 2020, 11:19 a.m. UTC
  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(+)
  

Comments

David Marchand Oct. 22, 2020, 12:55 p.m. UTC | #1
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?
  
Yunjian Wang Oct. 23, 2020, 9:05 a.m. UTC | #2
> -----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
  

Patch

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