lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110184915-mutt-send-email-mst@kernel.org>
Date: Sat, 10 Jan 2026 18:49:32 -0500
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Eugenio Pérez <eperezma@...hat.com>
Cc: linux-kernel@...r.kernel.org, virtualization@...ts.linux.dev,
	Maxime Coquelin <mcoqueli@...hat.com>,
	Laurent Vivier <lvivier@...hat.com>, Cindy Lu <lulu@...hat.com>,
	jasowang@...hat.com, Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
	Stefano Garzarella <sgarzare@...hat.com>,
	Yongji Xie <xieyongji@...edance.com>
Subject: Re: [PATCH v11 07/12] vduse: refactor vdpa_dev_add for goto err
 handling

On Fri, Jan 09, 2026 at 04:24:25PM +0100, Eugenio Pérez wrote:
> Next patches introduce more error paths in this function.  Refactor it
> so they can be accomodated through gotos.

accommodated

> 
> Acked-by: Jason Wang <jasowang@...hat.com>
> Reviewed-by: Xie Yongji <xieyongji@...edance.com>
> Signed-off-by: Eugenio Pérez <eperezma@...hat.com>
> ---
> 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/vduse_dev.c
> index 0386434577b5..f7a45f396cf8 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 = -ENOMEM;
> +		goto domain_err;
>  	}
>  
>  	ret = _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 = NULL;
> -		mutex_unlock(&dev->domain_lock);
> -		return ret;
> +		goto register_err;
>  	}
>  
>  	return 0;
> +
> +register_err:
> +	mutex_lock(&dev->domain_lock);
> +	vduse_domain_destroy(dev->domain);
> +	dev->domain = NULL;
> +	mutex_unlock(&dev->domain_lock);
> +
> +domain_err:
> +	put_device(&dev->vdev->vdpa.dev);
> +
> +	return ret;
>  }
>  
>  static void vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev)
> -- 
> 2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ