[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/5] rng: initialize file descriptor to -1
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 1/5] rng: initialize file descriptor to -1 |
Date: |
Tue, 17 Dec 2013 12:26:00 +0100 |
The file descriptor is never initialized to -1, which makes rng-random
close stdin if an object is created and immediately destroyed. If we
change it to -1, we also need to protect qemu_set_fd_handler from
receiving a bogus file descriptor.
Signed-off-by: Paolo Bonzini <address@hidden>
---
backends/rng-random.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 68dfc8a..136499d 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -123,15 +123,15 @@ static void rng_random_init(Object *obj)
NULL);
s->filename = g_strdup("/dev/random");
+ s->fd = -1;
}
static void rng_random_finalize(Object *obj)
{
RndRandom *s = RNG_RANDOM(obj);
- qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
-
if (s->fd != -1) {
+ qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
qemu_close(s->fd);
}
--
1.8.4.2
[Qemu-devel] [PATCH v2 5/5] monitor: add object-del (QMP) and object_del (HMP) command, Paolo Bonzini, 2013/12/17
[Qemu-devel] [PATCH v2 2/5] qom: fix leak for objects created with -object, Paolo Bonzini, 2013/12/17
Re: [Qemu-devel] [PATCH v2 0/5] Monitor commands for object-add/del, Igor Mammedov, 2013/12/18