aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-09-02 08:41:42 -0400
committerRusty Russell <rusty@rustcorp.com.au>2010-10-21 03:14:00 -0400
commit84ec06c59a14d0941dd58ca6793b24a7e86b3b85 (patch)
treed026b868f47f335e70ddb13575393de125dcd3be
parent96eb872b2a041b1536ccc6ae2fa87eb28f6e2bb2 (diff)
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 <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--drivers/char/virtio_console.c5
1 files changed, 4 insertions, 1 deletions
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,
410static ssize_t send_control_msg(struct port *port, unsigned int event, 410static ssize_t send_control_msg(struct port *port, unsigned int event,
411 unsigned int value) 411 unsigned int value)
412{ 412{
413 return __send_control_msg(port->portdev, port->id, event, value); 413 /* Did the port get unplugged before userspace closed it? */
414 if (port->portdev)
415 return __send_control_msg(port->portdev, port->id, event, value);
416 return 0;
414} 417}
415 418
416/* Callers must take the port->outvq_lock */ 419/* Callers must take the port->outvq_lock */