i2c: core: Add missing of_node_put()
Subsystems (2)
PATCH 1/1 i2c: core: Add missing of_node_put()
for_each_available_child_of_node performs an of_node_get on each iteration, so of_node_put() must be called on each iteration once we are finished with the node pointer.
--- drivers/i2c/i2c-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/i2c-core.c +3 -3
@@ -1428,9 +1428,9 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)dev_dbg (&adap->dev,"of_i2c: walking child nodes\n" );for_each_available_child_of_node (adap->dev.of_node, node) { -if (of_node_test_and_set_flag (node,OF_POPULATED )) -continue ; -of_i2c_register_device (adap, node); +if (!of_node_test_and_set_flag (node,OF_POPULATED )) +of_i2c_register_device (adap, node); +of_node_put (node); } }
Signature · 1 line
2.1.4
Quoted 3 lines · Jon Hunter
for_each_available_child_of_nodeperforms anof_node_geton each iteration, soof_node_put()must be called on each iteration once we are finished with the node pointer.
This is wrong, embedded of_get_next_available_child() correctly decrements ref counter of an examined node.
Quoted 13 lines
Signed-off-by Jon Hunter <[email protected]>--- drivers/i2c/i2c-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i2c/i2c-core.c +0
-0@@ -1428,9 +1428,9 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)dev_dbg (&adap->dev,"of_i2c: walking child nodes\n" );
drivers/i2c/i2c-core.c static void of_i2c_register_devices(struct i2c_adapter *adap) · line 1436
Quoted 10 lines
drivers/i2c/i2c-core.c +3
-3for_each_available_child_of_node (adap->dev.of_node, node) { -if (of_node_test_and_set_flag (node,OF_POPULATED )) -continue ; -of_i2c_register_device (adap, node); +if (!of_node_test_and_set_flag (node,OF_POPULATED )) +of_i2c_register_device (adap, node); +of_node_put (node); } }
--
With best wishes,
Vladimir
Quoted 7 lines · Vladimir Zapolskiy
Quoted 3 lines · Jon Hunter
for_each_available_child_of_nodeperforms anof_node_geton each iteration, soof_node_put()must be called on each iteration once we are finished with the node pointer.This is wrong, embedded
of_get_next_available_child()correctly decrements ref counter of an examined node.
Oh yes, sorry, I see that now. Sorry for the noise and mis-interpretation here :-(
Jon