gpudev: fix deadlocks when registering callback
PATCH 1/1 gpudev: fix deadlocks when registering callback
gpu_callback_lock was not released in some branches of the register helper.
While at it, set rte_errno in one branch.
Fixes 18cb07563165 ("gpudev: add event notification")
Signed-off-by David Marchand <[email protected]>
--- lib/gpudev/gpudev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/gpudev/gpudev.c +4 -1
@@ -408,6 +408,7 @@ rte_gpu_callback_register(int16_t dev_id, enum rte_gpu_event event, callback->function == function && callback->user_data == user_data) {GPU_LOG (INFO ,"callback already registered" ); +rte_rwlock_write_unlock (&gpu_callback_lock);return 0 ; } }
@@ -415,7 +416,9 @@ rte_gpu_callback_register(int16_t dev_id, enum rte_gpu_event event, callback =malloc (sizeof (*callback));if (callback ==NULL ) {GPU_LOG (ERR ,"cannot allocate callback" ); -return -ENOMEM ; +rte_rwlock_write_unlock (&gpu_callback_lock); + rte_errno =ENOMEM ; +return -rte_errno; } callback->function = function; callback->user_data = user_data;
Signature · 1 line
2.39.0
PATCH 1/1 gpudev: fix deadlocks when registering callback
Agree with the patch.
Thanks!
Quoted 9 lines · David Marchand
gpu_callback_lockwas not released in some branches of the register helper.
While at it, setrte_errnoin one branch.Fixes 18cb07563165 ("gpudev: add event notification")Signed-off-by David Marchand <[email protected]>
Acked-by Elena Agostini <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand