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 --- 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) { -- 2.25.1