5544c1b
From f3551d3640f3436b0e5505fd208cbd7bbfef411f Mon Sep 17 00:00:00 2001
d4cdad5
From: Amit Shah <amit.shah@redhat.com>
d4cdad5
Date: Fri, 2 Dec 2011 15:42:55 +0530
5544c1b
Subject: [PATCH] char: Disable write callback if throttled chardev is
d4cdad5
 detached
d4cdad5
d4cdad5
If a throttled chardev is detached from the frontend device, all future
d4cdad5
callbacks should be suppressed.  Not doing this results in a segfault.
d4cdad5
d4cdad5
Bugzilla: 745758
d4cdad5
Upstream: Not applicable, since throttling is a RHEL6-only feature.
d4cdad5
d4cdad5
Signed-off-by: Amit Shah <amit.shah@redhat.com>
bd56df9
Signed-off-by: Cole Robinson <crobinso@redhat.com>
d4cdad5
---
b6dd5ac
 qemu-char.c | 5 +++++
329b588
 1 file changed, 5 insertions(+)
d4cdad5
d4cdad5
diff --git a/qemu-char.c b/qemu-char.c
5544c1b
index bfc94a5..67a6d73 100644
d4cdad5
--- a/qemu-char.c
d4cdad5
+++ b/qemu-char.c
329b588
@@ -223,6 +223,11 @@ void qemu_chr_add_handlers(CharDriverState *s,
d4cdad5
         ++s->avail_connections;
d4cdad5
     }
d4cdad5
     if (!handlers) {
d4cdad5
+        if (s->write_blocked) {
d4cdad5
+            /* Ensure we disable the callback if we were throttled */
d4cdad5
+            s->chr_disable_write_fd_handler(s);
d4cdad5
+            /* s->write_blocked is cleared below */
d4cdad5
+        }
d4cdad5
         handlers = &null_handlers;
d4cdad5
     }
d4cdad5
     s->chr_can_read = handlers->fd_can_read;
d4cdad5
-- 
5544c1b
1.7.12.1
d4cdad5