From nobody Tue May 7 12:35:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1578471530; cv=none; d=zohomail.com; s=zohoarc; b=hBP4TUrfuyB6RL4CTHcnMioRmIEZgvWY+y+ypMQzy/too3V+cRETK/h83OvUs41cWDiOpQ0iySuymYlRkP0Cj8WOBC9rypuPJKp9UxkgppcHOBc4zIJLuuIg88PuNgldQ41ThcIrpLWSg1ezBlStjC6E9obK7oV3ACKgN3ypqTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578471530; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JTzcSxAo0JLuI5TcnwcWoHnJxzhEewcpEq4PNJ001S4=; b=OumMlWMpSrUokQiopwHUShRuPYqiWRejCfYa1EiPt80cmCELzXj2LQzoqoecIDH8vWqQCv4hzSaYc2ldgZnuNX6GEuBwlQ9kstY1NedhprbGGfNEF+W9uj9tPnriGFrxRFDZa3yOcSlKwnFTj3GdD0YJK9YSZ//khqP2DAxTSFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578471530218871.0588984207218; Wed, 8 Jan 2020 00:18:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-5xBSo_K7M92g0hR9gmS6rQ-1; Wed, 08 Jan 2020 03:18:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E9C9800A02; Wed, 8 Jan 2020 08:18:41 +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 3882B10013A7; Wed, 8 Jan 2020 08:18:41 +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 6350E81C9E; Wed, 8 Jan 2020 08:18:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0088IcvP008251 for ; Wed, 8 Jan 2020 03:18:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F64A60CD1; Wed, 8 Jan 2020 08:18:38 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC30760CC0 for ; Wed, 8 Jan 2020 08:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578471529; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JTzcSxAo0JLuI5TcnwcWoHnJxzhEewcpEq4PNJ001S4=; b=URTlsSsV92K1XqrgKG4X0vLTLVD+fIHermMzeM7DAgqbwT6GfpJf58iYDgfglUMdn9dqD3 Zd/exWRXHXP2o1AlYR8MpKHGPSv+KednkRaJhqtBAqdYG9RDqOrb6pA2EZQRqpUJ0pzryY yGHEy5Nvrx9S6D5bTdWlFNuVQHC98wc= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Jan 2020 09:18:29 +0100 Message-Id: <45c362bcfa30f515f6fcd60085b041291e2a49f9.1578471437.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] virchrdev: Don't leak @dev member of virChrdevHashEntry struct 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.84 on 10.5.11.22 X-MC-Unique: 5xBSo_K7M92g0hR9gmS6rQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When opening a console to a domain, we put a tuple of {path, virStreamPtr} into a hash table that's private to the domain. This is to ensure only one client at most has the console stream open. Later, when the console is closed, the tuple is removed from the hash table and freed. Except, @path won't be freed. =3D=3D234102=3D=3D 60 bytes in 5 blocks are definitely lost in loss record = 436 of 651 =3D=3D234102=3D=3D at 0x4836753: malloc (vg_replace_malloc.c:307) =3D=3D234102=3D=3D by 0x5549110: g_malloc (in /usr/lib64/libglib-2.0.so.= 0.6000.6) =3D=3D234102=3D=3D by 0x5562D1E: g_strdup (in /usr/lib64/libglib-2.0.so.= 0.6000.6) =3D=3D234102=3D=3D by 0x4A5A917: virChrdevOpen (virchrdev.c:412) =3D=3D234102=3D=3D by 0x17B64645: qemuDomainOpenConsole (qemu_driver.c:1= 7309) =3D=3D234102=3D=3D by 0x4BC8031: virDomainOpenConsole (libvirt-domain.c:= 9662) =3D=3D234102=3D=3D by 0x13F854: remoteDispatchDomainOpenConsole (remote_= daemon_dispatch_stubs.h:9211) =3D=3D234102=3D=3D by 0x13F72F: remoteDispatchDomainOpenConsoleHelper (r= emote_daemon_dispatch_stubs.h:9178) =3D=3D234102=3D=3D by 0x4AB0685: virNetServerProgramDispatchCall (virnet= serverprogram.c:430) =3D=3D234102=3D=3D by 0x4AB01F0: virNetServerProgramDispatch (virnetserv= erprogram.c:302) =3D=3D234102=3D=3D by 0x4AB700B: virNetServerProcessMsg (virnetserver.c:= 136) =3D=3D234102=3D=3D by 0x4AB70CB: virNetServerHandleJob (virnetserver.c:1= 53) Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virchrdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index d4ca3188c5..7657c41ece 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -225,6 +225,7 @@ static void virChrdevHashEntryFree(void *data) /* delete lock file */ virChrdevLockFileRemove(ent->dev); =20 + g_free(ent->dev); g_free(ent); } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 12:35:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578471615; cv=none; d=zohomail.com; s=zohoarc; b=AKnCJt963a8QPvXsbPgcgFhLsOQttRYhSmdzGWkbo1SmIfj9ADtCA4CCiMGSD6/laL3g5Pj/ajoaO4MJHVYyYPae3KjyJB2ssLyDcNA8m0I4DUHoy4sMieeS35SlE4dtPXgzLHanjoe2Gj4Vct5KlAs0WbRitFL0PraZqk1tRbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578471615; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LtW+tLC0gnq6c4N0RaBCBt/nSVGsie4BtLSyjS2bJWQ=; b=BpTeyBkDWYp8/61Ufs2qrEbuYJJpnD12NdTKzhSzyiSBJm+Kl2XTDE+YKx43pALnFc02S7uSgdIvkMvcDkI1+EoRLtiNkrtJar/Pj1TmepxEtyoudnBesnJIlr/BSUdR9UpJfj8uUCfaqtG4B7uy5S9/vYQQ/K5Wg6M3HLMP4VA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578471615085142.8482470425845; Wed, 8 Jan 2020 00:20:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-Kd8qzPh9MbKjZzhnShZ4_Q-1; Wed, 08 Jan 2020 03:19:02 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E34EF107ACC7; Wed, 8 Jan 2020 08:18:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB8B8272B4; Wed, 8 Jan 2020 08:18:56 +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 6ED5E18089CF; Wed, 8 Jan 2020 08:18:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0088IdvF008260 for ; Wed, 8 Jan 2020 03:18:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3A6F60CD1; Wed, 8 Jan 2020 08:18:38 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CAA460CC0 for ; Wed, 8 Jan 2020 08:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578471614; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LtW+tLC0gnq6c4N0RaBCBt/nSVGsie4BtLSyjS2bJWQ=; b=hTlM4kI66hrgP1PhLqJi6nvjDrkj1UfMCQCmJiW3XduV6lACxMcqIx7HsKQuXydlN6ICpZ S9qQMwL2S+3+gaPZJ4SEvl0nWvduwqe0sXLYc4EbufKmB3rEP940xknszZ03S5lpLl0t5u 5RkQ45Z7F2kvYBrlHxOBAs9WmUaDkd4= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Jan 2020 09:18:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] virchrdev: Don't leak mutex if virChrdevAlloc() fails 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.84 on 10.5.11.23 X-MC-Unique: Kd8qzPh9MbKjZzhnShZ4_Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is only a theoretical leak, but in virChrdevAlloc() we initialize a mutex and if creating a hash table fails, then virChrdevFree() is called which because of incorrect check doesn't deinit the mutex. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virchrdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 7657c41ece..6e659a3783 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -311,7 +311,7 @@ static int virChrdevFreeClearCallbacks(void *payload, */ void virChrdevFree(virChrdevsPtr devs) { - if (!devs || !devs->hash) + if (!devs) return; =20 virMutexLock(&devs->lock); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 12:35:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1578471547; cv=none; d=zohomail.com; s=zohoarc; b=mrITn40mOOn3iiaRQAcDMZfiUdYXeavVyvssHg19h4Kt6YK9QrA9edHjLOJK91zsphpkmfatLGelwXOrPUVN8SURmk7h/Au+Mui2hav5ED5H3oUwkBqOP0bD+DGOigkM3uEQrJaC4o8Pazzy9xedEPJy9xFRgcO2UgvHStkcD/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578471547; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vKPHB/qQfdkN0TZ+7l3BPt+4mfeNQkQ0X6iz/3WArGw=; b=GfUR6E7yd5s1hK+7AppPB0mI9oX9RcV8LpNNwtiYzU7VOH9oU15lOgndfw85xRCX+a5BBSTpeSu99PBb55Ppo0ppz8Q8iijiPzHX5zx5fMJYp5loX6HC+Jif7uFUwQTCi7RXy9nvEh37JW+U3MFRvWtQ9IiHKbtHDc2gcbjOM4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578471547312677.6522733687437; Wed, 8 Jan 2020 00:19:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-kHbJ1Hh5O8m30xI6R_EtVA-1; Wed, 08 Jan 2020 03:19:02 -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 E1458800D4C; Wed, 8 Jan 2020 08:18:56 +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 BA6797FB77; Wed, 8 Jan 2020 08:18:56 +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 6A30C820F7; Wed, 8 Jan 2020 08:18:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0088IdYr008272 for ; Wed, 8 Jan 2020 03:18:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id C57DE60CD1; Wed, 8 Jan 2020 08:18:39 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D77860CC0 for ; Wed, 8 Jan 2020 08:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578471544; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vKPHB/qQfdkN0TZ+7l3BPt+4mfeNQkQ0X6iz/3WArGw=; b=bddcXcubcIJdATEekMH9XEZxeLWcVCF6mZY27k90KOGhZm2PyCBIoJ/QXgZhwXAdhLkLV/ qMCH9g5+WFdeR0fyD4GjP7g/54GEvJ0fgjFuqoGSbS0M2s90nq9vvrkQ0U876SSsfzai2G BmNzMIEnDoKoVjnHUJTperPMvvEAX0A= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Jan 2020 09:18:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] virchrdev: Use more g_autofree and VIR_AUTOCLOSE 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 X-MC-Unique: kHbJ1Hh5O8m30xI6R_EtVA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virchrdev.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 6e659a3783..766c264472 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -67,9 +67,9 @@ struct _virChrdevStreamInfo { */ static char *virChrdevLockFilePath(const char *dev) { - char *path =3D NULL; - char *sanitizedPath =3D NULL; - char *devCopy; + g_autofree char *path =3D NULL; + g_autofree char *sanitizedPath =3D NULL; + g_autofree char *devCopy =3D NULL; char *filename; char *p; =20 @@ -92,10 +92,7 @@ static char *virChrdevLockFilePath(const char *dev) =20 sanitizedPath =3D virFileSanitizePath(path); =20 - VIR_FREE(path); - VIR_FREE(devCopy); - - return sanitizedPath; + return g_steal_pointer(&sanitizedPath); } =20 /** @@ -107,10 +104,10 @@ static char *virChrdevLockFilePath(const char *dev) */ static int virChrdevLockFileCreate(const char *dev) { - char *path =3D NULL; + g_autofree char *path =3D NULL; int ret =3D -1; - int lockfd =3D -1; - char *pidStr =3D NULL; + g_autofree char *pidStr =3D NULL; + VIR_AUTOCLOSE lockfd =3D -1; pid_t pid; =20 /* build lock file path */ @@ -161,7 +158,6 @@ static int virChrdevLockFileCreate(const char *dev) _("Couldn't write to lock file for " "device '%s' in path '%s'"), dev, path); - VIR_FORCE_CLOSE(lockfd); unlink(path); goto cleanup; } @@ -170,9 +166,6 @@ static int virChrdevLockFileCreate(const char *dev) ret =3D 0; =20 cleanup: - VIR_FORCE_CLOSE(lockfd); - VIR_FREE(path); - VIR_FREE(pidStr); =20 return ret; } @@ -184,10 +177,8 @@ static int virChrdevLockFileCreate(const char *dev) */ static void virChrdevLockFileRemove(const char *dev) { - char *path =3D virChrdevLockFilePath(dev); - if (path) - unlink(path); - VIR_FREE(path); + g_autofree char *path =3D virChrdevLockFilePath(dev); + unlink(path); } #else /* #ifdef VIR_CHRDEV_LOCK_FILE_PATH */ /* file locking for character devices is disabled */ --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 12:35:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1578471548; cv=none; d=zohomail.com; s=zohoarc; b=j9KKbNXjTWrI+SVgF7MsP4JqoivyJGGlcUlVLtbxaeI8wj/8zXV3VEsUWA6Ah3jiIF9A72tPTswZR2eDV8dgTmWFIeL0Pb0xuoMgPdGo2kwO2FCiZqWan1dnfaO9oBXFAgefZW9JFDC2s5G57bJz8PMxaCniQ/L0F29iajD2Ws4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578471548; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AO1pHjtfGrwOBPrMf8Qu7+iuRyL9NGJ26wQY6Czzp5U=; b=fcG5kmOBkJiNlKLBnhI16ORDeSB+G5FfjAiSxzym1VmWWxbw7ri6JinYKevD/XplkxmOiZwTRJQkPzT9IdUee0UJ6itXHilbcVA8X38APeh7rL6zOod0BBAA4hZLLAetUWpg2eXm7oWfl64R+TE2BcYGJ0sceBhhcYefmoFpV4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578471548923745.1858305491779; Wed, 8 Jan 2020 00:19:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-WQERVMXbMuKbLDTK0UEmSg-1; Wed, 08 Jan 2020 03:19:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 707EE1050905; Wed, 8 Jan 2020 08:19:00 +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 47D0B10013A7; Wed, 8 Jan 2020 08:19:00 +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 E3EB8820F7; Wed, 8 Jan 2020 08:18:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0088IeHA008277 for ; Wed, 8 Jan 2020 03:18:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 95DBE60CD1; Wed, 8 Jan 2020 08:18:40 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E9D260CC0 for ; Wed, 8 Jan 2020 08:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578471547; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AO1pHjtfGrwOBPrMf8Qu7+iuRyL9NGJ26wQY6Czzp5U=; b=IpHRIaC5nU/Xd/9Edhnr6MqTXQcJW60DTzbkAE0UsQ2FO1DZ0fG/HEBMleByIxEn0KqiUj 8fII3uRzXxvIJ/9dGcT2+mk5OpGQNbgVs8/x3NSkhVAG7RGPDuXLJAibyCnafV3RF8Dgr4 rEYgv9UYNhCuCeaeMJo9qUs6S8P11Jw= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 8 Jan 2020 09:18:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] virchrdev: Drop needless 'cleanup' label in virChrdevLockFileCreate() 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.84 on 10.5.11.22 X-MC-Unique: WQERVMXbMuKbLDTK0UEmSg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virchrdev.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 766c264472..800e82869e 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -105,14 +105,13 @@ static char *virChrdevLockFilePath(const char *dev) static int virChrdevLockFileCreate(const char *dev) { g_autofree char *path =3D NULL; - int ret =3D -1; g_autofree char *pidStr =3D NULL; VIR_AUTOCLOSE lockfd =3D -1; pid_t pid; =20 /* build lock file path */ if (!(path =3D virChrdevLockFilePath(dev))) - goto cleanup; + return -1; =20 /* check if a log file and process holding the lock still exists */ if (virPidFileReadPathIfAlive(path, &pid, NULL) =3D=3D 0 && pid >=3D 0= ) { @@ -121,7 +120,7 @@ static int virChrdevLockFileCreate(const char *dev) _("Requested device '%s' is locked by " "lock file '%s' held by process %lld"), dev, path, (long long) pid); - goto cleanup; + return -1; } else { /* clean up the stale/corrupted/nonexistent lockfile */ unlink(path); @@ -142,14 +141,13 @@ static int virChrdevLockFileCreate(const char *dev) if (errno =3D=3D EACCES && geteuid() !=3D 0) { VIR_DEBUG("Skipping lock file creation for device '%s in path = '%s'.", dev, path); - ret =3D 0; - goto cleanup; + return 0; } virReportSystemError(errno, _("Couldn't create lock file for " "device '%s' in path '%s'"), dev, path); - goto cleanup; + return -1; } =20 /* write the pid to the file */ @@ -159,15 +157,11 @@ static int virChrdevLockFileCreate(const char *dev) "device '%s' in path '%s'"), dev, path); unlink(path); - goto cleanup; + return -1; } =20 /* we hold the lock */ - ret =3D 0; - - cleanup: - - return ret; + return 0; } =20 /** --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list