patches for DPDK stable branches
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, Elena Agostini <eagostini@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: [PATCH] gpudev: fix deadlocks when registering callback
Date: Tue,  3 Jan 2023 11:49:00 +0100	[thread overview]
Message-ID: <20230103104900.616477-1-david.marchand@redhat.com> (raw)

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")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/gpudev/gpudev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c
index 805719d00c..8f12abef23 100644
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -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;
-- 
2.39.0


             reply	other threads:[~2023-01-03 10:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 10:49 David Marchand [this message]
2023-01-29 15:36 ` eagostini
2023-01-31 10:14 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230103104900.616477-1-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=eagostini@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).