net/phy/fixed.c: fix a use-after-free
authorAdrian Bunk <bunk@kernel.org>
Sat, 2 Feb 2008 21:15:02 +0000 (23:15 +0200)
committerJeff Garzik <jeff@garzik.org>
Mon, 11 Feb 2008 16:15:36 +0000 (11:15 -0500)
This patch fixes a use-after-free introduced by
commit a79d8e93d300adb84cccc38ac396cfb118c238ad and spotted by the
Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/phy/fixed.c

index 73b6d39ef6b0b2c4b294a01cd896951c9db00e1e..ca9b040f9ad98015520e4b22b29e3178b12043f9 100644 (file)
@@ -236,12 +236,12 @@ module_init(fixed_mdio_bus_init);
 static void __exit fixed_mdio_bus_exit(void)
 {
        struct fixed_mdio_bus *fmb = &platform_fmb;
-       struct fixed_phy *fp;
+       struct fixed_phy *fp, *tmp;
 
        mdiobus_unregister(&fmb->mii_bus);
        platform_device_unregister(pdev);
 
-       list_for_each_entry(fp, &fmb->phys, node) {
+       list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
                list_del(&fp->node);
                kfree(fp);
        }