OSDN Git Service

virtio_console: free buffers after reset
authorMichael S. Tsirkin <mst@redhat.com>
Fri, 20 Apr 2018 17:24:23 +0000 (20:24 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 May 2018 14:53:40 +0000 (07:53 -0700)
commitdd807a784fd36f4136516d5858efb6473dda422c
treea89a81f401ef6adbd9585feb6b1a8d2bd84f65e8
parenta4fc9c518e70c6e1c9c897a99b028795235d83ca
virtio_console: free buffers after reset

commit a7a69ec0d8e4a58be7db88d33cbfa2912807bb2b upstream.

Console driver is out of spec. The spec says:
A driver MUST NOT decrement the available idx on a live
virtqueue (ie. there is no way to “unexpose” buffers).
and it does exactly that by trying to detach unused buffers
without doing a device reset first.

Defer detaching the buffers until device unplug.

Of course this means we might get an interrupt for
a vq without an attached port now. Handle that by
discarding the consumed buffer.

Reported-by: Tiwei Bie <tiwei.bie@intel.com>
Fixes: b3258ff1d6 ("virtio: Decrement avail idx on buffer detach")
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/virtio_console.c