diff options
author | Amit Shah <amit.shah@redhat.com> | 2013-07-29 04:53:46 (GMT) |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-07-29 05:20:47 (GMT) |
commit | c6017e793b932e84b1c998f9b4c08d74ff0ea9c0 (patch) | |
tree | aa150eca5cdcb617606cc6aa23ea340392106e6e /drivers/char/virtio_console.c | |
parent | 927cfb9788475abd5cf5e6566bb1cf46d29b0694 (diff) | |
download | linux-c6017e793b932e84b1c998f9b4c08d74ff0ea9c0.tar.xz |
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/virtio_console.c')
-rw-r--r-- | drivers/char/virtio_console.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 1b456fe..601962b 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) { 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); } /* |