com32/lib/pci/scan.c: Fix free_pci_domain()
authorHenri Roosen <henri.roosen@sigmatek.at>
Wed, 7 Sep 2011 07:16:11 +0000 (09:16 +0200)
committerH. Peter Anvin <hpa@linux.intel.com>
Mon, 12 Mar 2012 21:18:52 +0000 (14:18 -0700)
free_pci_domain is releasing the memory too early; should be out
of the for loops, because in the loop the memory is still dereferenced.

com32/lib/pci/scan.c

index e0974f9..fe00fc2 100644 (file)
@@ -579,14 +579,14 @@ void free_pci_domain(struct pci_domain *domain)
                                    free(func->dev_info);
                                free(func);
                            }
-                           free(slot);
                        }
+                       free(slot);
                    }
-                   free(bus);
                }
+               free(bus);
            }
-           free(domain);
        }
+       free(domain);
     }
 }