examples/l3fwd: fix missing unlock issue

Message ID tencent_221F3CE2A7B111333A16DF62235322503108@qq.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series examples/l3fwd: fix missing unlock issue |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Weiguo Li Nov. 4, 2023, 7:27 a.m. UTC
  The function l3fwd_get_free_event_port acquires a lock on
'evt_rsrc->evp.lock' at the beginning. This lock is expected
to be released at the first return statement, when no free
event port is available.

Fixes: aaf58cb85b62 ("examples/l3fwd: add event port and queue setup")
Cc: stable@dpdk.org

Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
---
 examples/l3fwd/l3fwd_event.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c
index 20be22c6db..40c69baafb 100644
--- a/examples/l3fwd/l3fwd_event.c
+++ b/examples/l3fwd/l3fwd_event.c
@@ -205,6 +205,7 @@  l3fwd_get_free_event_port(struct l3fwd_event_resources *evt_rsrc)
 
 	rte_spinlock_lock(&evt_rsrc->evp.lock);
 	if (index >= evt_rsrc->evp.nb_ports) {
+		rte_spinlock_unlock(&evt_rsrc->evp.lock);
 		printf("No free event port is available\n");
 		return -1;
 	}