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]
Date:   Tue, 3 Aug 2021 16:09:23 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Xie Yongji <xieyongji@...edance.com>, mst@...hat.com,
        stefanha@...hat.com, sgarzare@...hat.com, parav@...dia.com,
        hch@...radead.org, christian.brauner@...onical.com,
        rdunlap@...radead.org, willy@...radead.org,
        viro@...iv.linux.org.uk, axboe@...nel.dk, bcrl@...ck.org,
        corbet@....net, mika.penttila@...tfour.com,
        dan.carpenter@...cle.com, joro@...tes.org,
        gregkh@...uxfoundation.org, zhe.he@...driver.com,
        xiaodong.liu@...el.com, joe@...ches.com
Cc:     songmuchun@...edance.com,
        virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
        kvm@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v10 10/17] virtio: Handle device reset failure in
 register_virtio_device()


在 2021/7/29 下午3:34, Xie Yongji 写道:
> The device reset may fail in virtio-vdpa case now, so add checks to
> its return value and fail the register_virtio_device().


So the reset() would be called by the driver during remove as well, or 
is it sufficient to deal only with the reset during probe?

Thanks


>
> Signed-off-by: Xie Yongji <xieyongji@...edance.com>
> ---
>   drivers/virtio/virtio.c | 15 ++++++++++-----
>   1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index a15beb6b593b..8df75425fb43 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -349,7 +349,9 @@ int register_virtio_device(struct virtio_device *dev)
>   
>   	/* We always start by resetting the device, in case a previous
>   	 * driver messed it up.  This also tests that code path a little. */
> -	dev->config->reset(dev);
> +	err = dev->config->reset(dev);
> +	if (err)
> +		goto err_reset;
>   
>   	/* Acknowledge that we've seen the device. */
>   	virtio_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
> @@ -362,10 +364,13 @@ int register_virtio_device(struct virtio_device *dev)
>   	 */
>   	err = device_add(&dev->dev);
>   	if (err)
> -		ida_simple_remove(&virtio_index_ida, dev->index);
> -out:
> -	if (err)
> -		virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
> +		goto err_add;
> +
> +	return 0;
> +err_add:
> +	virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
> +err_reset:
> +	ida_simple_remove(&virtio_index_ida, dev->index);
>   	return err;
>   }
>   EXPORT_SYMBOL_GPL(register_virtio_device);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ