aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2013-07-18 20:59:26 +0530
committerAmit Shah <amit.shah@redhat.com>2013-07-25 19:05:28 +0530
commit076e81210c7105be320a9807e8ff2fb76e0a9b7d (patch)
treef4dcfe3a920b64eec72503b2855c0bbe49c94bba
parentf218052d8d8438fea0d1c3483434e315c7e82db8 (diff)
downloadvirtio-console-076e81210c7105be320a9807e8ff2fb76e0a9b7d.tar.gz
virtio: console: add locks around buffer removal in port unplug path
The removal functions act on the vqs, and the vq operations need to be locked. Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r--drivers/char/virtio_console.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 2b68075073fdc5..9cbed938275697 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1512,18 +1512,22 @@ static void remove_port_data(struct port *port)
{
struct port_buffer *buf;
+ spin_lock_irq(&port->inbuf_lock);
/* Remove unused data this port might have received. */
discard_port_data(port);
- reclaim_consumed_buffers(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);
+ spin_unlock_irq(&port->inbuf_lock);
+
+ spin_lock_irq(&port->outvq_lock);
+ reclaim_consumed_buffers(port);
/* Free pending buffers from the out-queue. */
while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
free_buf(buf, true);
+ spin_unlock_irq(&port->outvq_lock);
}
/*