]> mj.ucw.cz Git - pciutils.git/commitdiff
Removed memory leak in pci_generic_bus_scan().
authorMartin Mares <mj@ucw.cz>
Fri, 26 Dec 2003 20:07:46 +0000 (20:07 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 5 May 2006 12:18:08 +0000 (14:18 +0200)
lib/generic.c: Removed memory leak in pci_generic_bus_scan().
Reported by Gary Parnes <gary_parnes@terago.com>.
git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-5

ChangeLog
lib/generic.c

index 3d769e76510735f65e89d4766fd748d109156ddd..8ef4414acaf08d30ce45489551246556dace91fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-12-26  Martin Mares  <mj@ucw.cz>
 
+       * lib/generic.c: Removed memory leak in pci_generic_bus_scan().
+       Reported by Gary Parnes <gary_parnes@terago.com>.
+
        * Replaced obsolete syntax of __attribute__((unused)) in the middle of
        parameter declarations (which is no longer supported by GCC 3.1) by the
        current syntax (attribute at the end). Thanks to pixel@mandrakesoft.com
index 79e1eee1535fc7e2b37ffae5e07f22c4b347ad59..d4f26000f87c5fbaca8bedccc0cef4a8b1f3e3a5 100644 (file)
@@ -14,7 +14,7 @@ void
 pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
 {
   int dev, multi, ht;
-  struct pci_dev *t = pci_alloc_dev(a);
+  struct pci_dev *t;
 
   a->debug("Scanning bus %02x for devices...\n", bus);
   if (busmap[bus])
@@ -23,6 +23,7 @@ pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
       return;
     }
   busmap[bus] = 1;
+  t = pci_alloc_dev(a);
   t->bus = bus;
   for(dev=0; dev<32; dev++)
     {
@@ -61,6 +62,7 @@ pci_generic_scan_bus(struct pci_access *a, byte *busmap, int bus)
            }
        }
     }
+  pci_free_dev(t);
 }
 
 void