Patchwork [5/6] char: Detect chardev release by NULL handlers as well as NULL opaque

login
register
mail settings
Submitter Amit Shah
Date April 28, 2011, 7:30 a.m.
Message ID <da7d998bbb80f141ed5743418a4dfa5c1409e75f.1303975203.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/93190/
State New
Headers show

Comments

Amit Shah - April 28, 2011, 7:30 a.m.
Juan says he prefers these extra checks to ensure a user of a chardev is
releasing it.

Requested-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index eaf6571..5e04a20 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -197,7 +197,7 @@  void qemu_chr_add_handlers(CharDriverState *s,
                            IOEventHandler *fd_event,
                            void *opaque)
 {
-    if (!opaque) {
+    if (!opaque && !fd_can_read && !fd_read && !fd_event) {
         /* chr driver being released. */
         ++s->avail_connections;
     }