aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2013-07-29 00:53:46 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-07-29 01:20:47 -0400
commitc6017e793b932e84b1c998f9b4c08d74ff0ea9c0 (patch)
treeaa150eca5cdcb617606cc6aa23ea340392106e6e /drivers/char
parent927cfb9788475abd5cf5e6566bb1cf46d29b0694 (diff)
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> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char')
-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 1b456fe9b87a..601962b1708b 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1513,18 +1513,22 @@ static void remove_port_data(struct port *port)
1513{ 1513{
1514 struct port_buffer *buf; 1514 struct port_buffer *buf;
1515 1515
1516 spin_lock_irq(&port->inbuf_lock);
1516 /* Remove unused data this port might have received. */ 1517 /* Remove unused data this port might have received. */
1517 discard_port_data(port); 1518 discard_port_data(port);
1518 1519
1519 reclaim_consumed_buffers(port);
1520
1521 /* Remove buffers we queued up for the Host to send us data in. */ 1520 /* Remove buffers we queued up for the Host to send us data in. */
1522 while ((buf = virtqueue_detach_unused_buf(port->in_vq))) 1521 while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
1523 free_buf(buf, true); 1522 free_buf(buf, true);
1523 spin_unlock_irq(&port->inbuf_lock);
1524
1525 spin_lock_irq(&port->outvq_lock);
1526 reclaim_consumed_buffers(port);
1524 1527
1525 /* Free pending buffers from the out-queue. */ 1528 /* Free pending buffers from the out-queue. */
1526 while ((buf = virtqueue_detach_unused_buf(port->out_vq))) 1529 while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
1527 free_buf(buf, true); 1530 free_buf(buf, true);
1531 spin_unlock_irq(&port->outvq_lock);
1528} 1532}
1529 1533
1530/* 1534/*