bcma: propagate bcma_register_devices() error to host probe
Subsystems (2)
PATCH 1/1 bcma: propagate bcma_register_devices() error to host probe
bcma_bus_register() ignores the return value of bcma_register_devices(), which reports a failure when bcma_gpio_init() cannot register the GPIO chip. The error is silently discarded, so the bus is registered anyway and the host device stays bound with the bus half-initialized. On device removal bcma_bus_unregister() unconditionally calls gpiochip_remove() on a chip whose gpio_device was never registered, the failure paths of gpiochip_add_data() free it but leave chip->gpiodev dangling, and gpiochip_remove() dereferences it without any check, causing a NULL pointer dereference or use-after-free.
Fix it by checking the return value of bcma_register_devices() in bcma_bus_register() and propagating the error to the caller, so the host probe fails instead of leaving the device bound in a half-initialized state. This new failure exit can be taken after some cores were already registered, so make the SoC host probe failure path unregister them, as the PCI host already does.
--- drivers/bcma/host_soc.c | 1 + drivers/bcma/main.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/bcma/host_soc.c +1 -0
@@ -236,6 +236,7 @@ static int bcma_host_soc_probe(struct platform_device *pdev)return err; err_unmap_mmio: +bcma_unregister_cores (bus);iounmap (bus->mmio);return err; }
drivers/bcma/main.c +3 -2
@@ -477,8 +477,9 @@ int bcma_bus_register(struct bcma_bus *bus) }/* Register found cores */ -bcma_register_devices (bus); - + err =bcma_register_devices (bus); +if (err) +return err;bcma_info (bus,"Bus registered\n" );return 0 ;
Signature · 1 line
2.43.0