Re: [PATCH] fix: i2c: i2c_mux_add_adapter: fix child device_node reference leak on adapter registration failure

From: WenTao Liang

Date: Sat Jun 27 2026 - 23:57:44 EST




> 2026年6月26日 23:03,WenTao Liang <vulab@xxxxxxxxxxx> 写道:
>
> When the OF block successfully acquires a child device_node reference and
> stores it in priv->adap.dev.of_node, but the subsequent
> i2c_add_numbered_adapter or i2c_add_adapter call fails, the error path
> jumps to err_free_priv which only kfree's the priv without calling
> of_node_put on the stored child node, leaking the reference.
>
> Add of_node_put(priv->adap.dev.of_node) in the err_free_priv error path.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: a7ab72390b77 ("i2c: mux: add common data for every i2c-mux instance")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/i2c/i2c-mux.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 681a201c239b..68a4c34b5987 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -408,6 +408,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
> return 0;
>
> err_free_priv:
> + of_node_put(priv->adap.dev.of_node);
> kfree(priv);
> return ret;
> }
> --
> 2.39.5 (Apple Git-154)

Please ignore this patch. I will resend a proper version after
learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang