[PATCH 1/2] clk: bcm2835: aux: Fix potential use-after-free on unbind

Brian Masney masneyb at kernel.org
Mon Nov 30 09:27:24 PST 2026


Hi Guangshuo,

> The OF clock provider remains registered when the driver is unbound,
> although its onecell data is released by devres. A later clock lookup
> can access that freed data.
> 
> Manage the provider so it is removed before its data is released.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: 5e63dcc74b30 ("clk: bcm2835: Add a driver for the auxiliary peripheral clock gates.")
> Signed-off-by: Guangshuo Li <liguangshuo at mail.sdu.edu.cn>
> ---
>  drivers/clk/bcm/clk-bcm2835-aux.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/clk/bcm/clk-bcm2835-aux.c b/drivers/clk/bcm/clk-bcm2835-aux.c
> index 0fafa5cba442..8cba5cbff1d2 100644
> --- a/drivers/clk/bcm/clk-bcm2835-aux.c
> +++ b/drivers/clk/bcm/clk-bcm2835-aux.c
> @@ -48,8 +48,7 @@ static int bcm2835_aux_clk_probe(struct platform_device *pdev)
>  	onecell->hws[BCM2835_AUX_CLOCK_SPI2] =
>  		clk_hw_register_gate(dev, "aux_spi2", parent, 0, gate, 2, 0, NULL);

This just happens to be another spot that's not freed. Either, convert
this (plus the other callers) to use the devm_ variant, or set
'suppress_bind_attrs = true' since this is a builtin_platform_driver.

Brian

-- 
Brian Masney <masneyb at kernel.org>



More information about the linux-arm-kernel mailing list