[PATCH v8 3/3] virtio_console: Remove buffers from out_vq at port removal

From: Sjur BrÃndeland
Date: Tue Oct 30 2012 - 04:52:03 EST


From: Sjur BrÃndeland <sjur.brandeland@xxxxxxxxxxxxxx>

Remove buffers from the out-queue when a rproc_serial device
is removed. Rproc_serial communicates with remote processors
that may crash and leave buffers in the out-queue. But the
virtio_console device is not supposed to leave buffers in the
out-queue when a port is removed, so in this case throw a
warning.

Signed-off-by: Sjur BrÃndeland <sjur.brandeland@xxxxxxxxxxxxxx>
---
drivers/char/virtio_console.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 9ebadcb..3fa036a 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1521,6 +1521,16 @@ static void remove_port_data(struct port *port)
/* Remove buffers we queued up for the Host to send us data in. */
while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
free_buf(buf, true);
+
+ /*
+ * Check the out-queue for buffers. For VIRTIO_CONSOLE it is a
+ * bug if this happens. But for RPROC_SERIAL the remote processor
+ * may have crashed, leaving buffers hanging in the out-queue.
+ */
+ while ((buf = virtqueue_detach_unused_buf(port->out_vq))) {
+ WARN_ON_ONCE(!is_rproc_serial(port->portdev->vdev));
+ free_buf(buf, true);
+ }
}

/*
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/