From nobody Mon Feb 9 03:14:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585221530; cv=none; d=zohomail.com; s=zohoarc; b=b7Vlm9FFRxbA3kFCOZVM568hYzjSPPtqznNjNZyY68GxeEqWvuaz+fUyabPNC/3sFL9Y/TtvUGX1u1hbzPC1Q9XwRBUczHPPpR1E1/+1yX0gd81pPTBC01/XbzoxGqXyxZ6maQh1YCIiIjtx0dhTE5pbqOi76viKyEeqEIpfKJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585221530; 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=qGI+kY18kmSa/+FMylvW/7sYkoY0AK1HDws9IS+KsSc=; b=OesEXlgFAFSgoo4W0NGw9rdzJTQqT3SyOxXEDyz6otLDBISM+0bQtpeZp2ASSjbe1FO+PvXkC9KKoRe5osG9ZW9XpgBRpVkO46fOwSbmodF7yhSo6whikguztjbNKbWiLkL3D5Q1+MEIAj+pyblKJs8ydta+fMJaHa0Kj+TnRtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585221530141866.6229571396087; Thu, 26 Mar 2020 04:18:50 -0700 (PDT) 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-13-tH7a_t_HPWaiu_vAI0sXEQ-1; Thu, 26 Mar 2020 07:18:46 -0400 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 0ACD3802B69; Thu, 26 Mar 2020 11:18:39 +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 87D0E10002A9; Thu, 26 Mar 2020 11:18:38 +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 DEA7286FF7; Thu, 26 Mar 2020 11:18:37 +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 02QBIAjP018163 for ; Thu, 26 Mar 2020 07:18:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2250A60FFB; Thu, 26 Mar 2020 11:18:10 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9044A60FCC for ; Thu, 26 Mar 2020 11:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585221529; 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=qGI+kY18kmSa/+FMylvW/7sYkoY0AK1HDws9IS+KsSc=; b=iA99Fm/ZRe47uCIE2PeEUqaHo7HmnSj48i4U3vhJRmbWdV09dCJsGmACBIWOlFaY+TcjKg uXNac0hyynmb6SPuYmJxhDbRZt621MnORqjMM9uo2OPBY7zKJl8vYqCRn/rpL73eKFPW08 mOtJkpTBgkBsBIJvBHGGvEIybDX1p1E= X-MC-Unique: tH7a_t_HPWaiu_vAI0sXEQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemuSecurityChownCallback: Remove 'cleanup' section Date: Thu, 26 Mar 2020 12:18:02 +0100 Message-Id: <9d1e3dd3adc9887cc06fbdb9ae15d1efd09845c3.1585221445.git.pkrempa@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 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Treat the shortcut for chowning local files as a stand-alone section by returning success from it and refactor the rest so that the cleanup section is inline. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 570dc059e9..b1f7be50b4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -268,24 +268,20 @@ qemuSecurityChownCallback(const virStorageSource *src, } if (chown(src->path, uid, gid) < 0) - goto cleanup; - } else { - if (!(cpy =3D virStorageSourceCopy(src, false))) - goto cleanup; - - /* src file init reports errors, return -2 on failure */ - if (virStorageFileInit(cpy) < 0) { - ret =3D -2; - goto cleanup; - } + return -1; - if (virStorageFileChown(cpy, uid, gid) < 0) - goto cleanup; + return 0; } - ret =3D 0; + if (!(cpy =3D virStorageSourceCopy(src, false))) + return -1; + + /* src file init reports errors, return -2 on failure */ + if (virStorageFileInit(cpy) < 0) + return -2; + + ret =3D virStorageFileChown(cpy, uid, gid); - cleanup: save_errno =3D errno; virStorageFileDeinit(cpy); errno =3D save_errno; --=20 2.24.1