[PATCH 1/4] kvm tools: fix sigsegv in irq__exit

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

 



From: Sasha Levin <levinsasha928@xxxxxxxxx>

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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux