Re: [PATCH] net: phy: mdio_bus: add missing device_del() in mdiobus_register() error handling
From: David Miller
Date: Fri Jan 18 2019 - 14:08:18 EST
From: Thomas Petazzoni <thomas.petazzoni@xxxxxxxxxxx>
Date: Wed, 16 Jan 2019 10:53:58 +0100
> The current code in __mdiobus_register() doesn't properly handle
> failures returned by the devm_gpiod_get_optional() call: it returns
> immediately, without unregistering the device that was added by the
> call to device_register() earlier in the function.
> This leaves a stale device, which then causes a NULL pointer
> dereference in the code that handles deferred probing:
> The actual error that we had from devm_gpiod_get_optional() was
> -EPROBE_DEFER, due to the GPIO being provided by a driver that is
> probed later than the Ethernet controller driver.
> To fix this, we simply add the missing device_del() invocation in the
> error path.
> Fixes: 69226896ad636 ("mdio_bus: Issue GPIO RESET to PHYs")
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@xxxxxxxxxxx>
Applied and queued up for -stable.