cpufreq: sun50i: fix memory leak in dt_has_supported_hw()
The for_each_child_of_node() loop does not decrement the child node refcount before the break instruction, even though the node is no longer required. This can be avoided with the new for_each_child_of_node_scoped() macro that removes the need for any of_node_put(). Fixes: fa5aec9561cf ("cpufreq: sun50i: Add support for opp_supported_hw") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
1613e604df
commit
6282fba6ab
@ -131,7 +131,7 @@ static const struct of_device_id cpu_opp_match_list[] = {
|
|||||||
static bool dt_has_supported_hw(void)
|
static bool dt_has_supported_hw(void)
|
||||||
{
|
{
|
||||||
bool has_opp_supported_hw = false;
|
bool has_opp_supported_hw = false;
|
||||||
struct device_node *np, *opp;
|
struct device_node *np;
|
||||||
struct device *cpu_dev;
|
struct device *cpu_dev;
|
||||||
|
|
||||||
cpu_dev = get_cpu_device(0);
|
cpu_dev = get_cpu_device(0);
|
||||||
@ -142,7 +142,7 @@ static bool dt_has_supported_hw(void)
|
|||||||
if (!np)
|
if (!np)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for_each_child_of_node(np, opp) {
|
for_each_child_of_node_scoped(np, opp) {
|
||||||
if (of_find_property(opp, "opp-supported-hw", NULL)) {
|
if (of_find_property(opp, "opp-supported-hw", NULL)) {
|
||||||
has_opp_supported_hw = true;
|
has_opp_supported_hw = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user