Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] vdpa/vp_vdpa: infinite loop in vp_vdpa_reset() on surprise
  removal or fault
--

commit 877ae67f265800ae2b653bd6932dd2f6fa55c959
Author: Yuho Choi <[email protected]>

vdpa/vp_vdpa: Wait for device reset to complete

This commit polls device_status in vp_vdpa_reset() until it reads back 0
before freeing the MSI-X IRQs and returning.

> diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c 
> b/drivers/vdpa/virtio_pci/vp_vdpa.c
> index 646efd9384fba..eba82ff253ea3 100644
> --- a/drivers/vdpa/virtio_pci/vp_vdpa.c
> +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
[ ... ]
> @@ -236,6 +237,9 @@ static int vp_vdpa_reset(struct vdpa_device *vdpa)
>       u8 s = vp_vdpa_get_status(vdpa);
>  
>       vp_modern_set_status(mdev, 0);
> +     /* Wait for the reset to complete */
> +     while (vp_modern_get_status(mdev))
> +             fsleep(1000);

[Severity: High]
Can this loop sleep forever if the PCI device is surprise-removed or
fails to reset?

On PCI hot-unplug, vp_vdpa_remove() unregisters the vDPA device, which
triggers vdpa_reset() -> vp_vdpa_reset() while MMIO reads from
cfg->device_status return 0xff on every iteration.  Without a timeout or
a check for pci_device_is_present(mdev->pci_dev), vp_vdpa_reset() hangs
indefinitely while holding vdpa->cf_lock and blocks vp_vdpa_free_irq()
and device teardown.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to