From nobody Mon Feb 9 10:32:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1646643726; cv=none; d=zohomail.com; s=zohoarc; b=mUP+1q4vzrMqKKoBxIk357I78yT+ZZ2wLzJPimZe8vQyI+5h0N5c3g59LgpnhG+98Pk5hbTqSJ+13kTv98NGTF+fG6UUafPfPVmUV7TWnuowMnpOnI4n/3voGdV8e7/LQEKMTcjq2tZKtBJO00Nx2k1XPbUUxSo+RkY5A6RWLwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646643726; 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=sn3ARB0jfteuwXxisn2lJFdnuelKsCoqPbgaUekdEz0=; b=IYDnU8iIH0cqITSRVJIDZ+XFChMCMpUdOwl0EpQppndexuobcPwH3/fHI5lCxb3QJ6ovaIQHsAuUuUUtM9Qd0OSPLVGFhjj6/5psygnn8rrYp9VATK9p0j9KLeMYFsTtC5z1AKgbfSyfKjy89bUP6lfQurKtQrJ2WSlg7LKKLrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1646643726393793.5585666448196; Mon, 7 Mar 2022 01:02:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-kIapZWJePl-Owfv8f-BcuA-1; Mon, 07 Mar 2022 04:01:26 -0500 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 671832999B2B; Mon, 7 Mar 2022 09:01:20 +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 50324145FBA3; Mon, 7 Mar 2022 09:01:20 +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 07F381931BFA; Mon, 7 Mar 2022 09:01:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E66F21931BDE for ; Mon, 7 Mar 2022 09:01:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A869A1F470; Mon, 7 Mar 2022 09:01:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EE711F476 for ; Mon, 7 Mar 2022 09:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646643726; 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=sn3ARB0jfteuwXxisn2lJFdnuelKsCoqPbgaUekdEz0=; b=TQaVjRbeLG07+W7mdQgsup2VFLLhacMD58fC0UB2GYV0z3XNHSRNBr27qoD6HMVRt8fQ90 TuSe8LCmU9w2GW2HgHLzB1hdhoPSfJxBIzxtXheG+fFWWcIvrWsiyd9dsQhqWVslIUfo6H FLjScDJBvID56kfPM8NHNyXCezc0BgI= X-MC-Unique: kIapZWJePl-Owfv8f-BcuA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/17] lxcSetupFuse: Cleanup error paths Date: Mon, 7 Mar 2022 10:00:58 +0100 Message-Id: <5072c9a300e68cc550b34f0d83aed321e95431fb.1646643526.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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: 1646643727996100003 Content-Type: text/plain; charset="utf-8" In the lxcSetupFuse() function there are multiple cleanup labels, but with a bit of rewrite they can be joined into one 'error' label. And while at it, set the @f argument only in the successful path (currently is set in error case too). Signed-off-by: Michal Privoznik --- src/lxc/lxc_fuse.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index 683d01525f..274702736f 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -314,19 +314,19 @@ lxcSetupFuse(struct virLXCFuse **f, { int ret =3D -1; struct fuse_args args =3D FUSE_ARGS_INIT(0, NULL); - struct virLXCFuse *fuse =3D g_new0(virLXCFuse, 1); + g_autofree struct virLXCFuse *fuse =3D g_new0(virLXCFuse, 1); =20 fuse->def =3D def; =20 if (virMutexInit(&fuse->lock) < 0) - goto cleanup2; + return -1; =20 fuse->mountpoint =3D g_strdup_printf("%s/%s.fuse/", LXC_STATE_DIR, def= ->name); =20 if (g_mkdir_with_parents(fuse->mountpoint, 0777) < 0) { virReportSystemError(errno, _("Cannot create %s"), fuse->mountpoint); - goto cleanup1; + goto error; } =20 /* process name is libvirt_lxc */ @@ -334,29 +334,29 @@ lxcSetupFuse(struct virLXCFuse **f, fuse_opt_add_arg(&args, "-odirect_io") =3D=3D -1 || fuse_opt_add_arg(&args, "-oallow_other") =3D=3D -1 || fuse_opt_add_arg(&args, "-ofsname=3Dlibvirt") =3D=3D -1) - goto cleanup1; + goto error; =20 fuse->ch =3D fuse_mount(fuse->mountpoint, &args); if (fuse->ch =3D=3D NULL) - goto cleanup1; + goto error; =20 fuse->fuse =3D fuse_new(fuse->ch, &args, &lxcProcOper, sizeof(lxcProcOper), fuse->def); if (fuse->fuse =3D=3D NULL) { - fuse_unmount(fuse->mountpoint, fuse->ch); - goto cleanup1; + goto error; } =20 + *f =3D g_steal_pointer(&fuse); ret =3D 0; cleanup: fuse_opt_free_args(&args); - *f =3D fuse; return ret; - cleanup1: + + error: + if (fuse->ch) + fuse_unmount(fuse->mountpoint, fuse->ch); g_free(fuse->mountpoint); virMutexDestroy(&fuse->lock); - cleanup2: - g_free(fuse); goto cleanup; } =20 --=20 2.34.1