[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/13] rng: initialize file descriptor to -1
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 08/13] rng: initialize file descriptor to -1 |
Date: |
Wed, 18 Dec 2013 11:59:58 -0500 |
From: Paolo Bonzini <address@hidden>
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>
Reviewed-By: Igor Mammedov <address@hidden>
Signed-off-by: Luiz Capitulino <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.1.4
- [Qemu-devel] [PULL 00/13] QMP queue, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 11/13] monitor: add object-add (QMP) and object_add (HMP) command, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 12/13] monitor: add object-del (QMP) and object_del (HMP) command, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 13/13] qemu-monitor: HMP cpu-add wrapper, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 01/13] vl: add missing transition debug->finish_migrate, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 06/13] qemu-option: Remove qemu_opts_create_nofail, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 03/13] hw/core/qdev: Delete dead code, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 02/13] error: Add error_abort, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 04/13] hw: Remove assert_no_error usages, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 08/13] rng: initialize file descriptor to -1,
Luiz Capitulino <=
- [Qemu-devel] [PULL 09/13] qom: fix leak for objects created with -object, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 05/13] target-i386: Remove assert_no_error usage, Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 07/13] qerror: Remove assert_no_error(), Luiz Capitulino, 2013/12/18
- [Qemu-devel] [PULL 10/13] qom: catch errors in object_property_add_child, Luiz Capitulino, 2013/12/18
- Re: [Qemu-devel] [PULL 00/13] QMP queue, Peter Maydell, 2013/12/19