Skip to content

Commit

Permalink
net: kernel BUG at drivers/net/phy/mdio_bus.c:165!
Browse files Browse the repository at this point in the history
kernel BUG at drivers/net/phy/mdio_bus.c:165!
Unable to handle kernel NULL pointer dereference at virtual address 00000000

How?

mdiobus_alloc() sets bus->state = MDIOBUS_ALLOCATED.

mdiobus_register() sets bus->state = MDIOBUS_REGISTERED but then can
   fail (mdiobus_scan()) returning an error to the caller.

The caller aborts correctly with mdiobus_free() which does:
        if (bus->state == MDIOBUS_ALLOCATED) {
                kfree(bus);
                return;
        }

        BUG_ON(bus->state != MDIOBUS_UNREGISTERED);

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Krzysztof Halasa authored and David S. Miller committed Dec 17, 2008
1 parent 9a3de25 commit e8e5752
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ int mdiobus_register(struct mii_bus *bus)
return -EINVAL;
}

bus->state = MDIOBUS_REGISTERED;

mutex_init(&bus->mdio_lock);

if (bus->reset)
Expand All @@ -123,6 +121,9 @@ int mdiobus_register(struct mii_bus *bus)
}
}

if (!err)
bus->state = MDIOBUS_REGISTERED;

pr_info("%s: probed\n", bus->name);

return err;
Expand Down

0 comments on commit e8e5752

Please sign in to comment.