kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] kvm tools: fix sigsegv in irq__exit
@ 2012-05-09 12:24 Sasha Levin
  2012-05-09 12:24 ` [PATCH 2/4] kvm tools: use bitwise 'and' in kvm-ipc Sasha Levin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sasha Levin @ 2012-05-09 12:24 UTC (permalink / raw)
  To: penberg; +Cc: gorcunov, mingo, asias.hejun, kvm, Sasha Levin

From: Sasha Levin <levinsasha928@gmail.com>

We free the structure, but never remove them from the tree or list, then
we freed them the next time we ran through that structure.

This patch also simplifies irq__exit a bit.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/x86/irq.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/tools/kvm/x86/irq.c b/tools/kvm/x86/irq.c
index dc07f28..e83df99 100644
--- a/tools/kvm/x86/irq.c
+++ b/tools/kvm/x86/irq.c
@@ -179,25 +179,18 @@ int irq__exit(struct kvm *kvm)
 
 	free(irq_routing);
 
-	ent = rb_first(&pci_tree);
-	for (;;) {
+	while ((ent = rb_first(&pci_tree))) {
 		struct pci_dev *dev;
-		struct rb_node *next;
 		struct irq_line *line;
-		struct list_head *node, *tmp;
-
-		if (!ent)
-			break;
-
-		next = rb_next(ent);
 
 		dev = rb_entry(ent, struct pci_dev, node);
-		list_for_each_safe(node, tmp, &dev->lines) {
-			line = list_entry(node, struct irq_line, node);
+		while (!list_empty(&dev->lines)) {
+			line = list_first_entry(&dev->lines, struct irq_line, node);
+			list_del(&line->node);
 			free(line);
 		}
+		rb_erase(&dev->node, &pci_tree);
 		free(dev);
-		ent = next;
 	}
 
 	return 0;
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-09 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 12:24 [PATCH 1/4] kvm tools: fix sigsegv in irq__exit Sasha Levin
2012-05-09 12:24 ` [PATCH 2/4] kvm tools: use bitwise 'and' in kvm-ipc Sasha Levin
2012-05-09 12:24 ` [PATCH 3/4] kvm tools: use accessor function for virtio-9p FIDs Sasha Levin
2012-05-09 12:24 ` [PATCH 4/4] kvm tools: increase amount of " Sasha Levin
2012-05-09 12:29 ` [PATCH 1/4] kvm tools: fix sigsegv in irq__exit Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).