]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
xen: fix memory leak in Xen PCI MSI/MSI-X allocator.
authorJiri Slaby <jslaby@suse.cz>
Sat, 6 Nov 2010 09:06:49 +0000 (10:06 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 8 Nov 2010 16:30:00 +0000 (11:30 -0500)
Stanse found that xen_setup_msi_irqs leaks memory when
xen_allocate_pirq fails. Free the memory in that fail path.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: xen-devel@lists.xensource.com
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
arch/x86/pci/xen.c

index 117f5b8daf7515bf8ac03deb5522a011c286280d..d7b5109f7a9c28b05e120da3eec295b1716f543e 100644 (file)
@@ -147,8 +147,10 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
                irq = xen_allocate_pirq(v[i], 0, /* not sharable */
                        (type == PCI_CAP_ID_MSIX) ?
                        "pcifront-msi-x" : "pcifront-msi");
-               if (irq < 0)
-                       return -1;
+               if (irq < 0) {
+                       ret = -1;
+                       goto free;
+               }
 
                ret = set_irq_msi(irq, msidesc);
                if (ret)
@@ -164,7 +166,7 @@ error:
        if (ret == -ENODEV)
                dev_err(&dev->dev, "Xen PCI frontend has not registered" \
                        " MSI/MSI-X support!\n");
-
+free:
        kfree(v);
        return ret;
 }