Skip to content

Commit f63e7c8

Browse files
Yuuoniykuba-moo
authored andcommitted
net: dsa: mv88e6xxx: Fix fwnode reference leaks in mv88e6xxx_port_setup_leds
Fix multiple fwnode reference leaks: 1. The function calls fwnode_get_named_child_node() to get the "leds" node, but never calls fwnode_handle_put(leds) to release this reference. 2. Within the fwnode_for_each_child_node() loop, the early return paths that don't properly release the "led" fwnode reference. This fix follows the same pattern as commit d029ede ("net dsa: qca8k: fix usages of device_get_named_child_node()") Fixes: 94a2a84 ("net: dsa: mv88e6xxx: Support LED control") Cc: [email protected] Signed-off-by: Miaoqian Lin <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3a5f555 commit f63e7c8

File tree

1 file changed

+13
-4
lines changed
  • drivers/net/dsa/mv88e6xxx

1 file changed

+13
-4
lines changed

drivers/net/dsa/mv88e6xxx/leds.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port)
779779
continue;
780780
if (led_num > 1) {
781781
dev_err(dev, "invalid LED specified port %d\n", port);
782-
return -EINVAL;
782+
ret = -EINVAL;
783+
goto err_put_led;
783784
}
784785

785786
if (led_num == 0)
@@ -823,17 +824,25 @@ int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port)
823824
init_data.devname_mandatory = true;
824825
init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d:0%d", chip->info->name,
825826
port, led_num);
826-
if (!init_data.devicename)
827-
return -ENOMEM;
827+
if (!init_data.devicename) {
828+
ret = -ENOMEM;
829+
goto err_put_led;
830+
}
828831

829832
ret = devm_led_classdev_register_ext(dev, l, &init_data);
830833
kfree(init_data.devicename);
831834

832835
if (ret) {
833836
dev_err(dev, "Failed to init LED %d for port %d", led_num, port);
834-
return ret;
837+
goto err_put_led;
835838
}
836839
}
837840

841+
fwnode_handle_put(leds);
838842
return 0;
843+
844+
err_put_led:
845+
fwnode_handle_put(led);
846+
fwnode_handle_put(leds);
847+
return ret;
839848
}

0 commit comments

Comments
 (0)