Commit d029edef authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller

net dsa: qca8k: fix usages of device_get_named_child_node()

The documentation for device_get_named_child_node() mentions this
important point:

"
The caller is responsible for calling fwnode_handle_put() on the
returned fwnode pointer.
"

Add fwnode_handle_put() to avoid leaked references.

Fixes: 1e264f9d ("net: dsa: qca8k: add LEDs basic support")
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d37fe425
...@@ -431,8 +431,11 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p ...@@ -431,8 +431,11 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p
init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d", init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d",
priv->internal_mdio_bus->id, priv->internal_mdio_bus->id,
port_num); port_num);
if (!init_data.devicename) if (!init_data.devicename) {
fwnode_handle_put(led);
fwnode_handle_put(leds);
return -ENOMEM; return -ENOMEM;
}
ret = devm_led_classdev_register_ext(priv->dev, &port_led->cdev, &init_data); ret = devm_led_classdev_register_ext(priv->dev, &port_led->cdev, &init_data);
if (ret) if (ret)
...@@ -441,6 +444,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p ...@@ -441,6 +444,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p
kfree(init_data.devicename); kfree(init_data.devicename);
} }
fwnode_handle_put(leds);
return 0; return 0;
} }
...@@ -471,9 +475,13 @@ qca8k_setup_led_ctrl(struct qca8k_priv *priv) ...@@ -471,9 +475,13 @@ qca8k_setup_led_ctrl(struct qca8k_priv *priv)
* the correct port for LED setup. * the correct port for LED setup.
*/ */
ret = qca8k_parse_port_leds(priv, port, qca8k_port_to_phy(port_num)); ret = qca8k_parse_port_leds(priv, port, qca8k_port_to_phy(port_num));
if (ret) if (ret) {
fwnode_handle_put(port);
fwnode_handle_put(ports);
return ret; return ret;
}
} }
fwnode_handle_put(ports);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment