Message ID | 20220601075211.2117596-1-wanjiabing@vivo.com |
---|---|
State | New |
Headers | show |
Series | leds: Add of_node_put() before return | expand |
Quoting Wan Jiabing (2022-06-01 00:52:03) > Fix following coccicheck warning: > drivers/leds/rgb/leds-qcom-lpg.c:1107:2-34: WARNING: Function for_each_available_child_of_node should have of_node_put() before return around line 1110. > drivers/leds/rgb/leds-qcom-lpg.c:1286:1-33: WARNING: Function for_each_available_child_of_node should have of_node_put() before return around line 1289. > > Early exits from for_each_available_child_of_node should decrement the > node reference counter. > > Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG") > Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> > --- Reviewed-by: Stephen Boyd <swboyd@chromium.org>
diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c index 02f51cc61837..05f064543444 100644 --- a/drivers/leds/rgb/leds-qcom-lpg.c +++ b/drivers/leds/rgb/leds-qcom-lpg.c @@ -1106,8 +1106,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) i = 0; for_each_available_child_of_node(np, child) { ret = lpg_parse_channel(lpg, child, &led->channels[i]); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } info[i].color_index = led->channels[i]->color; info[i].intensity = 0; @@ -1285,8 +1287,10 @@ static int lpg_probe(struct platform_device *pdev) for_each_available_child_of_node(pdev->dev.of_node, np) { ret = lpg_add_led(lpg, np); - if (ret) + if (ret) { + of_node_put(np); return ret; + } } for (i = 0; i < lpg->num_channels; i++)
Fix following coccicheck warning: drivers/leds/rgb/leds-qcom-lpg.c:1107:2-34: WARNING: Function for_each_available_child_of_node should have of_node_put() before return around line 1110. drivers/leds/rgb/leds-qcom-lpg.c:1286:1-33: WARNING: Function for_each_available_child_of_node should have of_node_put() before return around line 1289. Early exits from for_each_available_child_of_node should decrement the node reference counter. Fixes: 24e2d05d1b68 ("leds: Add driver for Qualcomm LPG") Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> --- drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)