From nobody Mon May 13 21:10:18 2024 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=1647505433; cv=none; d=zohomail.com; s=zohoarc; b=noWO61WdovBRYPabOvfTSEd7vs4efJCbWO9WLJcuqa3gTCDyRYneqf/JfOreWCyx4LUo/kqvxqH9+QUlF6VtoXoBZ4V4+O5wOH1A/eY7Nl3W3GzzaZJW/bOjYEcjKbz/YWy1g8Lz/K6dmvViEU3sGNtwRvZYypEwZzhX1FGZuQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647505433; 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=HYznAArEVIWPyWbCIwDr9xWCx/JrbtMkmERtyKIAUDk=; b=RAQXLrmLduztcRLFXQZM/RDGnVptXAZfz5A2r4w6ZPbt/nzzRLhK/CfypNmn1a9+mCHcuIm+dl55M1JUJ8Y3VQTAlSoZhL5CDkE1CgutcGupWJLF3sXkoxdgTVmroEDlMYWsu7GpuZESr+/no7rokHOkvglqw3JckJpgG5SMizc= 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 1647505433086812.922561639965; Thu, 17 Mar 2022 01:23:53 -0700 (PDT) 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-141-c8ODR0UWOkixiYQFj7JCjQ-1; Thu, 17 Mar 2022 04:23:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B7A51875069; Thu, 17 Mar 2022 08:23:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26A94142B965; Thu, 17 Mar 2022 08:23:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E1D7D1940365; Thu, 17 Mar 2022 08:23:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4E906194035E for ; Thu, 17 Mar 2022 08:23:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0156F401053; Thu, 17 Mar 2022 08:23:43 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DABC400F24 for ; Thu, 17 Mar 2022 08:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647505431; 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=HYznAArEVIWPyWbCIwDr9xWCx/JrbtMkmERtyKIAUDk=; b=BnjXVwWGGwpHSYKJf4scJkmLgYfOd24hocnlmiKfzUir4jVY+UdlhjJSplgI0BpPm5WXEw i7qMBk9yPKqrPx0kU0gs4IVGq77OjoPogt+t0uswGJi5KewClN3Q1KOk1p3NNTLLQnlG24 cTZ+z3L1v/YwqqGRmWRsCVFuMlgLJqs= X-MC-Unique: c8ODR0UWOkixiYQFj7JCjQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName() Date: Thu, 17 Mar 2022 09:23:40 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: 1647505433808100001 Content-Type: text/plain; charset="utf-8" The virNetDevGenerateName() function uses a global array of virNetDevGenName structs to find next unused name for network device. This obviously needs some locking and in fact each member of the array has its own lock. However, these members are not virObjects, they are just plain structs, therefore VIR_WITH_MUTEX_LOCK_GUARD() must be used instead of VIR_WITH_OBJECT_LOCK_GUARD() to lock individual mutexes. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- src/util/virnetdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5df48af60c..1c15a475fa 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3616,7 +3616,7 @@ virNetDevGenerateName(char **ifname, virNetDevGenName= Type type) g_autofree char *try =3D NULL; int id =3D 0; =20 - VIR_WITH_OBJECT_LOCK_GUARD(&virNetDevGenNames[type].mutex) { + VIR_WITH_MUTEX_LOCK_GUARD(&virNetDevGenNames[type].mutex) { id =3D ++virNetDevGenNames[type].lastID; =20 /* reset before overflow */ --=20 2.34.1