Skip to contentSkip to conversation

ipmi:ipmb: Fix refcount leak in ipmi_ipmb_probe

PATCH Applied Miaoqian Lin 2 participants 2 messages May 12, 2022 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipmi:ipmb: Fix refcount leak in ipmi_ipmb_probe

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 00d93611f002 ("ipmi:ipmb: Add the ability to have a separate slave and master device")
---
 drivers/char/ipmi/ipmi_ipmb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_ipmb.c +1 -0
index b81b862532fb..a8bfe0ade082 100644
@@ -476,6 +476,7 @@ static int ipmi_ipmb_probe(struct i2c_client *client,
 	slave_np = of_parse_phandle(dev->of_node, "slave-dev", 0);
 	if (slave_np) {
 		slave_adap = of_get_i2c_adapter_by_node(slave_np);
+		of_node_put(slave_np);
 		if (!slave_adap) {
 			dev_notice(&client->dev,
 				   "Could not find slave adapter\n");
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Miaoqian Lin

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Thanks, applied and backport requested for 5.17.

-corey

Quoted 22 lines
Fixes 00d93611f002 ("ipmi:ipmb: Add the ability to have a separate slave and master device")
---
 drivers/char/ipmi/ipmi_ipmb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_ipmb.c +1 -0
index b81b862532fb..a8bfe0ade082 100644
@@ -476,6 +476,7 @@ static int ipmi_ipmb_probe(struct i2c_client *client,
 	slave_np = of_parse_phandle(dev->of_node, "slave-dev", 0);
 	if (slave_np) {
 		slave_adap = of_get_i2c_adapter_by_node(slave_np);
+		of_node_put(slave_np);
 		if (!slave_adap) {
 			dev_notice(&client->dev,
 				   "Could not find slave adapter\n");
Signature · 1 line
2.25.1