From nobody Mon Feb 9 09:09:59 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 643302D5C7A for ; Wed, 14 Jan 2026 18:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768416565; cv=none; b=dtIs7GLT1wculeVab4jmEDYYLeicMAbwK2Dtq0h0sP/CFA9quoa+Bl+6ZG44Bbf2gGLWbkKrRu1Lx2EaDdjywup16HKWCKeHJR57PTP6nMR+/3sSq6nWq1a7SBs9HIlzaiuBNo69t0XPHSmZVxnP6bgUWJOlmpxSBxG/Vls3G2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768416565; c=relaxed/simple; bh=7WkiaFQXSJ9rftIhsrRPJDimmW5NW0HIRoiDY1dK0Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ewTd2XVyrVJgknmW8/6hAHpsmncaGsBxjB/V72YzW7UzB2ef2LEkSc7AaEimvZSqA0ULFX3EbkUPWhOdb1jVd4oHxR02E97Gn/ZrOCu/lpgIFIsLOu7mBN/4Ccq+iu7a/syLbb2qqbSXRCwiEvMHnDFbtfF/FkcPy2Tur3MxDw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GHq/mjK8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GHq/mjK8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768416560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f3i9Zfy1TusGrkGCrHl6HZAZANNAsOmF+dD9gg6kSpw=; b=GHq/mjK85rTu5Ceg/ne0kkKrZ1puYX+ZpEsj2TuDVMpia+dJcl4dUpmUzpE+GbEFgrcKMm XfVfIVeaKRn0KF/l24rbo36tYA6cLwDl81IycD6aTPx3fRvqNDEqmH8PDHcSRjryrCWwBo NDJhrn+5aSFJV11xBXjR9MDtSnqZVAs= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-W2buN95eNdGwIeVFWbHChQ-1; Wed, 14 Jan 2026 13:49:17 -0500 X-MC-Unique: W2buN95eNdGwIeVFWbHChQ-1 X-Mimecast-MFC-AGG-ID: W2buN95eNdGwIeVFWbHChQ_1768416556 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A88C81956096; Wed, 14 Jan 2026 18:49:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.103]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0CA1519560B4; Wed, 14 Jan 2026 18:49:12 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: "Michael S . Tsirkin " Cc: Maxime Coquelin , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , virtualization@lists.linux.dev, jasowang@redhat.com, Stefano Garzarella , Yongji Xie , linux-kernel@vger.kernel.org, Cindy Lu , Laurent Vivier Subject: [PATCH v12 07/13] vduse: refactor vdpa_dev_add for goto err handling Date: Wed, 14 Jan 2026 19:48:33 +0100 Message-ID: <20260114184839.926884-8-eperezma@redhat.com> In-Reply-To: <20260114184839.926884-1-eperezma@redhat.com> References: <20260114184839.926884-1-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Next patches introduce more error paths in this function. Refactor it so they can be accommodated through gotos. Acked-by: Jason Wang Reviewed-by: Xie Yongji Signed-off-by: Eugenio P=C3=A9rez --- v12: Fix typo in patch message (MST). v6: New in v6. --- drivers/vdpa/vdpa_user/vduse_dev.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_dev.c index 68290c3d9d8f..43851b0711ac 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -2171,21 +2171,27 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev,= const char *name, dev->bounce_size); mutex_unlock(&dev->domain_lock); if (!dev->domain) { - put_device(&dev->vdev->vdpa.dev); - return -ENOMEM; + ret =3D -ENOMEM; + goto domain_err; } =20 ret =3D _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num); if (ret) { - put_device(&dev->vdev->vdpa.dev); - mutex_lock(&dev->domain_lock); - vduse_domain_destroy(dev->domain); - dev->domain =3D NULL; - mutex_unlock(&dev->domain_lock); - return ret; + goto register_err; } =20 return 0; + +register_err: + mutex_lock(&dev->domain_lock); + vduse_domain_destroy(dev->domain); + dev->domain =3D NULL; + mutex_unlock(&dev->domain_lock); + +domain_err: + put_device(&dev->vdev->vdpa.dev); + + return ret; } =20 static void vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *d= ev) --=20 2.52.0