fix: i2c: i2c_mux_add_adapter: fix child device_node reference leak on adapter registration failure
Subsystems (4)
PATCH 1/1 fix: i2c: i2c_mux_add_adapter: fix child device_node reference leak on adapter registration failure
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.
--- drivers/i2c/i2c-mux.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/i2c-mux.c +1 -0
@@ -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; }
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 28 lines
2026年6月26日 23:03,WenTao Liang <[email protected]> 写道:
When the OF block successfully acquires a child
device_nodereference and
stores it inpriv->adap.dev.of_node, but the subsequenti2c_add_numbered_adapterori2c_add_adaptercall fails, the error path jumps toerr_free_privwhich only kfree's the priv without callingof_node_puton the stored child node, leaking the reference.Add
of_node_put(priv->adap.dev.of_node)in theerr_free_priverror path.Fixes a7ab72390b77 ("i2c: mux: add common data for every i2c-mux instance")Signed-off-by WenTao Liang <[email protected]>---
drivers/i2c/i2c-mux.c| 1 +1 file changed, 1 insertion(+)drivers/i2c/i2c-mux.c +0
-0@@ -408,6 +408,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,return 0 ;
err_free_priv:drivers/i2c/i2c-mux.c +1
-0+of_node_put (priv->adap.dev.of_node);
Quoted 5 lines
kfree(priv); return ret; }Signature · 1 line
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