From 84ec06c59a14d0941dd58ca6793b24a7e86b3b85 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Thu, 2 Sep 2010 18:11:42 +0530 Subject: [PATCH] virtio: console: Check if portdev is valid in send_control_msg() A portdev may have been hot-unplugged while a port was open()ed. Skip sending control messages when the portdev isn't valid. Signed-off-by: Amit Shah Signed-off-by: Rusty Russell --- drivers/char/virtio_console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index e15dbe72edbf..e1d382b15532 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -410,7 +410,10 @@ static ssize_t __send_control_msg(struct ports_device *portdev, u32 port_id, static ssize_t send_control_msg(struct port *port, unsigned int event, unsigned int value) { - return __send_control_msg(port->portdev, port->id, event, value); + /* Did the port get unplugged before userspace closed it? */ + if (port->portdev) + return __send_control_msg(port->portdev, port->id, event, value); + return 0; } /* Callers must take the port->outvq_lock */ -- 2.34.1