ソースを参照

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>
Amit Shah 12 年 前
コミット
c6017e793b
1 ファイル変更6 行追加2 行削除
  1. 6 2
      drivers/char/virtio_console.c

+ 6 - 2
drivers/char/virtio_console.c

@@ -1513,18 +1513,22 @@ static void remove_port_data(struct port *port)
 {
 {
 	struct port_buffer *buf;
 	struct port_buffer *buf;
 
 
+	spin_lock_irq(&port->inbuf_lock);
 	/* Remove unused data this port might have received. */
 	/* Remove unused data this port might have received. */
 	discard_port_data(port);
 	discard_port_data(port);
 
 
-	reclaim_consumed_buffers(port);
-
 	/* Remove buffers we queued up for the Host to send us data in. */
 	/* Remove buffers we queued up for the Host to send us data in. */
 	while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
 	while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
 		free_buf(buf, true);
 		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. */
 	/* Free pending buffers from the out-queue. */
 	while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
 	while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
 		free_buf(buf, true);
 		free_buf(buf, true);
+	spin_unlock_irq(&port->outvq_lock);
 }
 }
 
 
 /*
 /*