Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5549fb25 authored by Amit Shah's avatar Amit Shah Committed by Rusty Russell
Browse files

virtio: console: add locking in port unplug path



Port unplug can race with close() in port_fops_release().
port_fops_release() already takes the necessary locks, ensure
unplug_port() does that too.

Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent c6017e79
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1542,6 +1542,7 @@ static void unplug_port(struct port *port)
	list_del(&port->list);
	spin_unlock_irq(&port->portdev->ports_lock);

	spin_lock_irq(&port->inbuf_lock);
	if (port->guest_connected) {
		port->guest_connected = false;
		port->host_connected = false;
@@ -1550,6 +1551,7 @@ static void unplug_port(struct port *port)
		/* Let the app know the port is going down. */
		send_sigio_to_port(port);
	}
	spin_unlock_irq(&port->inbuf_lock);

	if (is_console_port(port)) {
		spin_lock_irq(&pdrvdata_lock);