[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT a979670] Correctly free nd structure

From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT a979670] Correctly free nd structure
Date: Mon, 05 Oct 2009 14:53:20 -0000

From: Glauber Costa <address@hidden>

When we "free" a NICInfo structure, we can leak pointers, since we don't do
much more than setting used = 0.

We free() the model parameter, but we don't set it to NULL. This means that
a new user of this structure will see garbage in there. It was not noticed
before because reusing a NICInfo is not that common, but it can be, for
users of device pci hotplug.

A user hit it, described at https://bugzilla.redhat.com/show_bug.cgi?id=524022

This patch memset's the whole structure, guaranteeing that anyone reusing it
will see a fresh NICinfo. Also, we free some other strings that are currently

This codebase is quite old, so this patch should feed all stable trees.

Signed-off-by: Glauber Costa <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/net.c b/net.c
index 2686f78..bcc5176 100644
--- a/net.c
+++ b/net.c
@@ -2803,8 +2803,13 @@ void net_client_uninit(NICInfo *nd)
-    nd->used = 0;
-    free((void *)nd->model);
+    qemu_free((void *)nd->model);
+    qemu_free((void *)nd->name);
+    qemu_free((void *)nd->devaddr);
+    qemu_free((void *)nd->id);
+    memset(nd, 0, sizeof(*nd));
 static int net_host_check_device(const char *device)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]