[syslinux] [PATCH] com32/lib/pci/scan.c: Fix free_pci_domain()

Henri Roosen
Wed, 07 Sep 2011 07:16:11 -0000

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 |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index e0974f9..fe00fc2 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -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);
     }
 }

--
1.7.4.1