Skip to contentSkip to conversation

misc: eeprom: idt_89hpesx: fix fwnode leak in idt_get_fw_data()

PATCH In review manushprajwal 1 participant 1 message Aug 23 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 misc: eeprom: idt_89hpesx: fix fwnode leak in idt_get_fw_data()

device_for_each_child_node() takes a reference on each fwnode it returns, which the loop body must release before it stops iterating. When idt_ee_match_id() finds a matching EEPROM child, the loop breaks out immediately without calling fwnode_handle_put() on that fwnode, leaking the reference. Add the missing fwnode_handle_put() call before the break.

---
 drivers/misc/eeprom/idt_89hpesx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/eeprom/idt_89hpesx.c +3 -1
index e056d2dea..f32c27855 100644
@@ -1082,8 +1082,10 @@ static void idt_get_fw_data(struct idt_89hpesx_dev *pdev)
 
 	device_for_each_child_node(dev, fwnode) {
 		ee_id = idt_ee_match_id(fwnode);
-		if (ee_id)
+		if (ee_id) {
+			fwnode_handle_put(fwnode);
 			break;
+		}
 
 		dev_warn(dev, "Skip unsupported EEPROM device %pfw\n", fwnode);
 	}
Signature · 1 line
2.46.2.windows.1