aboutsummaryrefslogtreecommitdiff
path: root/backends/rng-random.c
diff options
context:
space:
mode:
Diffstat (limited to 'backends/rng-random.c')
-rw-r--r--backends/rng-random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 68dfc8a9c6..136499d305 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);
}