From patchwork Tue Jan 3 10:49:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 121526 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21E0EA00C2; Tue, 3 Jan 2023 11:49:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17271427EB; Tue, 3 Jan 2023 11:49:15 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id CD1FC42B7E for ; Tue, 3 Jan 2023 11:49:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672742952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pJ4HcaW8UAHGyr7HlvIFWAYnrQD8L5eEQqpY08MnUfE=; b=VRvyWAfbO1ExUTxGDJQH/4Cs+eyxSKa8/i9ORCmhv2301BW56xoDeFf7cpy221dooEDVVf GZkur/B4++OvbiBxWO9rBIZSvoQGN8lAUImJ0P8a86Q/XX3e2mDQ+73/QF83NRBZgVMLAz w5hujHHDguqkh+QWnzZloCPjyY78aN0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-423-GS6B-fwTMOeEH8BDwIgksw-1; Tue, 03 Jan 2023 05:49:04 -0500 X-MC-Unique: GS6B-fwTMOeEH8BDwIgksw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C81F8F6E87; Tue, 3 Jan 2023 10:49:04 +0000 (UTC) Received: from dmarchan.redhat.com (ovpn-193-100.brq.redhat.com [10.40.193.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2722940C2064; Tue, 3 Jan 2023 10:49:02 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Elena Agostini , Thomas Monjalon Subject: [PATCH] gpudev: fix deadlocks when registering callback Date: Tue, 3 Jan 2023 11:49:00 +0100 Message-Id: <20230103104900.616477-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Elena Agostini --- 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;