Commit-ID: 424dfdfb24dfa6b98c567a5c6585e4a5139ddba8 Gitweb: http://git.kernel.org/tip/424dfdfb24dfa6b98c567a5c6585e4a5139ddba8 Author: Sasha Levin <levinsasha928@xxxxxxxxx> AuthorDate: Wed, 9 May 2012 14:24:45 +0200 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Wed, 9 May 2012 15:26:36 +0300 kvm tools: fix sigsegv in irq__exit 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> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- 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; -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html