RE: [PATCH v6 01/15] clk: starfive: jh7110-sys: Fix memory leak in reset controller register

From: Hal Feng

Date: Mon Nov 23 2026 - 01:29:04 EST


> On 26.10.08 20:33, Changhuang Liang wrote:
> auxiliary_device_init() returns an error before device_initialize() is called, so
> the release callback never runs on this path and the rdev allocated in
> jh7110_reset_controller_register() is leaked.
>
> Free rdev when auxiliary_device_init() fails.
>
> Fixes: edab7204afe5 ("clk: starfive: Add StarFive JH7110 system clock driver")
> Signed-off-by: Changhuang Liang <changhuang.liang@xxxxxxxxxxxxxxxx>
> ---
> drivers/clk/starfive/clk-starfive-jh7110-sys.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c
> b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
> index 847c0a39e5ab..1d460a03f936 100644
> --- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c
> +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
> @@ -360,8 +360,10 @@ int jh7110_reset_controller_register(struct
> jh71x0_clk_priv *priv,
> adev->id = adev_id;
>
> ret = auxiliary_device_init(adev);
> - if (ret)
> + if (ret) {
> + kfree(rdev);
> return ret;
> + }
>
> ret = auxiliary_device_add(adev);
> if (ret) {

Acked-by: Hal Feng <hal.feng@xxxxxxxxxxxxxxxx>

Best regards,
Hal