From nobody Sun Feb 8 22:50:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643792444; cv=none; d=zohomail.com; s=zohoarc; b=RXZohuOf4cFsO4zZhjlSOmzZPvwK9oqGTaszNlNyR0jVsJKXvi4+ZHN9dEl3AwvJxV0ebl2XqEh9WvBDgsu0qDd7LZt0Vc+o/JKwZqyNkRi1mVzpFddhBf9wcQjh5NzHVKrNBGSEYeE+vPZnwe69QFh5UPgP5YBg2tyML9QHrQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643792444; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=O0/8lddFi3eg4kE+dhUnCDXzHAeaiBv2mx6Jf3ArSUQ=; b=T6kmcRAkRS9oQW7n+vexhDHMs/ltrJoo/IXH0UtYHeAcMKbJLUg6vsncmdmE8hyIuQ6GDfbFwU+ZNugEObqVia4/hfW8tqOMXjuGJxpIWFc3ervDXTeR9UOZ4/qz4dLH491fI/OkfJTIcY5c3nWOoSX/zGt7/6BlltR2qhb4mps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1643792444116883.6840706685211; Wed, 2 Feb 2022 01:00:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-7J-9dTyOPV-Ps83UFBfEtg-1; Wed, 02 Feb 2022 04:00:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E64FA1083F60; Wed, 2 Feb 2022 09:00:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 838B462D68; Wed, 2 Feb 2022 09:00:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7059B4CA93; Wed, 2 Feb 2022 09:00:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21290XPx031326 for ; Wed, 2 Feb 2022 04:00:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 38D5262D69; Wed, 2 Feb 2022 09:00:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE2E462D68 for ; Wed, 2 Feb 2022 09:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643792443; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=O0/8lddFi3eg4kE+dhUnCDXzHAeaiBv2mx6Jf3ArSUQ=; b=DV3oUpWT606chXuveEsqJDV8nr1JlAHSWW4rNRz21xz2M1ZtpoCGnTLP3q9ClNRQ3SVStf 14GcKHmVVvkm6hAQLg0lWNxWFFlfvMH/fUy+Abv+E5X7u/CxPMhPFO6C45/L3jNjLa+Rc9 88C7jlDKUraJH69cm8myLtmEzC+Ni94= X-MC-Unique: 7J-9dTyOPV-Ps83UFBfEtg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] virnodedeviceobj: Don't unlock virNodeDeviceObj in virNodeDeviceObjListRemove() Date: Wed, 2 Feb 2022 10:00:24 +0100 Message-Id: <3feb57b887cdef940e052f1e721f6b2f4193aa8d.1643792202.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643792446029100001 Content-Type: text/plain; charset="utf-8" When virNodeDeviceObjListRemove() is called, the passed virNodeDeviceObj is removed from internal list of node devices and then unrefed and unlocked. While the former is warranted (the object was refed at the beginning of the function) the unlock is not. In fact, it's wrong from conceptual POV. We still want threads working on the object tu mutually exclude each other. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- v2 of: https://listman.redhat.com/archives/libvir-list/2022-February/msg00036.html diff to v1: - Fixed test driver which worked around broken logic Note, there is similar problem with virNodeDeviceObjListForEachRemove() which removes objects from the list, even without lock, but that happens only with mdevs and I have none to test with. src/conf/virnodedeviceobj.c | 2 +- src/test/test_driver.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 2e4ef2df3c..7a560349d4 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -524,7 +524,7 @@ virNodeDeviceObjListRemove(virNodeDeviceObjList *devs, virObjectRWLockWrite(devs); virObjectLock(obj); virNodeDeviceObjListRemoveLocked(devs, obj); - virNodeDeviceObjEndAPI(&obj); + virObjectUnref(obj); virObjectRWUnlock(devs); } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9e1fc65972..f900123941 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6810,7 +6810,7 @@ testDestroyVport(testDriver *privconn, 0); =20 virNodeDeviceObjListRemove(privconn->devs, obj); - virObjectUnref(obj); + virNodeDeviceObjEndAPI(&obj); =20 virObjectEventStateQueue(privconn->eventState, event); return 0; @@ -7797,8 +7797,6 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) =20 virObjectLock(obj); virNodeDeviceObjListRemove(driver->devs, obj); - virObjectUnref(obj); - obj =3D NULL; =20 cleanup: virNodeDeviceObjEndAPI(&obj); --=20 2.34.1