* [PATCH] virtio_input: reset device if input_register_device() fails
@ 2026-08-05 3:29 Xiong Weimin
2026-08-05 5:29 ` Michael S. Tsirkin
0 siblings, 1 reply; 4+ messages in thread
From: Xiong Weimin @ 2026-08-05 3:29 UTC (permalink / raw)
To: virtualization, linux-kernel, Gerd Hoffmann, Michael S. Tsirkin
Cc: Jason Wang, Jason Wang, Xuan Zhuo, Eugenio Pérez, stable,
Xiong Weimin
Probe marks the device DRIVER_OK with virtio_device_ready() before
calling input_register_device(). If registration fails, the error path
cleared vi->ready and called del_vqs() while the device was still live,
so the device could keep DMA to queues that were already torn down.
Match remove/freeze: call virtio_reset_device() on that path before
tearing down the virtqueues.
Fixes: 271c865161c5 ("Add virtio-input driver.")
Cc: stable@vger.kernel.org
Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
---
drivers/virtio/virtio_input.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index deec24e8e..1a87be4c8 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -331,6 +331,7 @@ static int virtinput_probe(struct virtio_device *vdev)
spin_lock_irqsave(&vi->lock, flags);
vi->ready = false;
spin_unlock_irqrestore(&vi->lock, flags);
+ virtio_reset_device(vdev);
err_mt_init_slots:
input_free_device(vi->idev);
err_input_alloc:
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] virtio_input: reset device if input_register_device() fails
2026-08-05 3:29 [PATCH] virtio_input: reset device if input_register_device() fails Xiong Weimin
@ 2026-08-05 5:29 ` Michael S. Tsirkin
2026-08-05 6:19 ` Xiong Weimin
2026-08-05 6:47 ` Xiong Weimin
0 siblings, 2 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2026-08-05 5:29 UTC (permalink / raw)
To: Xiong Weimin
Cc: virtualization, linux-kernel, Gerd Hoffmann, Jason Wang,
Jason Wang, Xuan Zhuo, Eugenio Pérez, stable
On Wed, Aug 05, 2026 at 11:29:31AM +0800, Xiong Weimin wrote:
> Probe marks the device DRIVER_OK with virtio_device_ready() before
> calling input_register_device(). If registration fails, the error path
> cleared vi->ready and called del_vqs() while the device was still live,
> so the device could keep DMA to queues that were already torn down.
>
> Match remove/freeze: call virtio_reset_device() on that path before
> tearing down the virtqueues.
>
> Fixes: 271c865161c5 ("Add virtio-input driver.")
> Cc: stable@vger.kernel.org
for each of these patches: is this a real or a theoretical issue?
stable rules preclude the later kind.
> Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
> ---
> drivers/virtio/virtio_input.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
> index deec24e8e..1a87be4c8 100644
> --- a/drivers/virtio/virtio_input.c
> +++ b/drivers/virtio/virtio_input.c
> @@ -331,6 +331,7 @@ static int virtinput_probe(struct virtio_device *vdev)
> spin_lock_irqsave(&vi->lock, flags);
> vi->ready = false;
> spin_unlock_irqrestore(&vi->lock, flags);
> + virtio_reset_device(vdev);
> err_mt_init_slots:
> input_free_device(vi->idev);
> err_input_alloc:
> --
> 2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] virtio_input: reset device if input_register_device() fails
2026-08-05 5:29 ` Michael S. Tsirkin
@ 2026-08-05 6:19 ` Xiong Weimin
2026-08-05 6:47 ` Xiong Weimin
1 sibling, 0 replies; 4+ messages in thread
From: Xiong Weimin @ 2026-08-05 6:19 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: virtualization, linux-kernel, Gerd Hoffmann, Jason Wang,
Jason Wang, Xuan Zhuo, Eugenio Pérez, stable
On Wed, Aug 05, 2026 at 01:29:28AM -0400, Michael S. Tsirkin wrote:
> for each of these patches: is this a real or a theoretical issue?
> stable rules preclude the later kind.
For this virtio_input patch: theoretical for stable.
On the failing path, virtio_device_ready() has run, but
virtinput_fill_evt() has not, so the event queue still has no buffers.
I have no evidence of device DMA into torn-down queues here; the change
is lifecycle hygiene matching remove/freeze (clear DRIVER_OK before
del_vqs()).
I will drop Cc: stable on a v2 and keep the fix for mainline only.
I will answer the same question separately on the virtio_pci and
virtio_mmio threads.
Thanks,
Xiong
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio_input: reset device if input_register_device() fails
2026-08-05 5:29 ` Michael S. Tsirkin
2026-08-05 6:19 ` Xiong Weimin
@ 2026-08-05 6:47 ` Xiong Weimin
1 sibling, 0 replies; 4+ messages in thread
From: Xiong Weimin @ 2026-08-05 6:47 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: virtualization, linux-kernel, Gerd Hoffmann, Jason Wang,
Jason Wang, Xuan Zhuo, Eugenio Pérez, stable
On Wed, Aug 05, 2026 at 01:29:28AM -0400, Michael S. Tsirkin wrote:
> for each of these patches: is this a real or a theoretical issue?
> stable rules preclude the later kind.
For this virtio_input patch: theoretical for stable.
On the failing path, virtio_device_ready() has run, but
virtinput_fill_evt() has not, so the event queue still has no buffers.
I have no evidence of device DMA into torn-down queues here; the change
is lifecycle hygiene matching remove/freeze (clear DRIVER_OK before
del_vqs()).
I will drop Cc: stable on a v2 and keep the fix for mainline only.
I will answer the same question separately on the virtio_pci and
virtio_mmio threads.
Thanks,
Xiong
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-05 6:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 3:29 [PATCH] virtio_input: reset device if input_register_device() fails Xiong Weimin
2026-08-05 5:29 ` Michael S. Tsirkin
2026-08-05 6:19 ` Xiong Weimin
2026-08-05 6:47 ` Xiong Weimin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox