Skip to content

Commit

Permalink
virtio: console: Ignore port name update request if name already set
Browse files Browse the repository at this point in the history
We don't allow port name changes dynamically for a port.  So any
requests by the host to change the name are ignored.

Before this patch, if the hypervisor sent a port name while we had one
set already, we would leak memory equivalent to the size of the old
name.

This scenario wasn't expected so far, but with the suspend-resume
support, we'll send the VIRTIO_CONSOLE_PORT_READY message after restore,
which can get us into this situation.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Amit Shah authored and Rusty Russell committed Nov 2, 2011
1 parent 286f9a2 commit 291024e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,13 @@ static void handle_control_message(struct ports_device *portdev,
send_sigio_to_port(port);
break;
case VIRTIO_CONSOLE_PORT_NAME:
/*
* If we woke up after hibernation, we can get this
* again. Skip it in that case.
*/
if (port->name)
break;

/*
* Skip the size of the header and the cpkt to get the size
* of the name that was sent
Expand Down

0 comments on commit 291024e

Please sign in to comment.