Re: [PATCH] virtio_pci: properly clean up MSI-X state when initialization fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 14, 2014 at 08:23:26PM -0700, Anthony Liguori wrote:
> From: Anthony Liguori <aliguori@xxxxxxxxxx>
> 
> If MSI-X initialization fails after setting msix_enabled = 1, then
> the device is left in an inconsistent state.  This would normally
> only happen if there was a bug in the device emulation but it still
> should be handled correctly.
> 
> Cc: Matt Wilson <msw@xxxxxxxxxx>
> Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> Cc: Michael Tsirkin <mst@xxxxxxxxxx>
> Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>

Reviewed-by: Matt Wilson <msw@xxxxxxxxxx>

--msw

> ---
>  drivers/virtio/virtio_pci.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index 9cbac33..3d2c2a5 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -357,7 +357,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
>  	v = ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
>  	if (v == VIRTIO_MSI_NO_VECTOR) {
>  		err = -EBUSY;
> -		goto error;
> +		goto error_msix_used;
>  	}
>  
>  	if (!per_vq_vectors) {
> @@ -369,11 +369,15 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
>  				  vp_vring_interrupt, 0, vp_dev->msix_names[v],
>  				  vp_dev);
>  		if (err)
> -			goto error;
> +			goto error_msix_used;
>  		++vp_dev->msix_used_vectors;
>  	}
>  	return 0;
> +error_msix_used:
> +	v = --vp_dev->msix_used_vectors;
> +	free_irq(vp_dev->msix_entries[v].vector, vp_dev);
>  error:
> +	vp_dev->msix_enabled = 0;
>  	vp_free_vectors(vdev);
>  	return err;
>  }
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux