Commit 0dd8d2c8 authored by Liang He's avatar Liang He Committed by Michael Ellerman

powerpc/perf: Add missing of_node_put()s in imc-pmu.c

In update_events_in_group(), of_find_node_by_phandle() will return
a node pointer with refcount incremented. The reference should be
dropped with of_node_put() in the failure path or when it is not used
anymore.
Signed-off-by: default avatarLiang He <windhl@126.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Reviewed-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20220618071353.4059000-1-windhl@126.com
parent 6b2d17d5
...@@ -240,8 +240,10 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu) ...@@ -240,8 +240,10 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
ct = of_get_child_count(pmu_events); ct = of_get_child_count(pmu_events);
/* Get the event prefix */ /* Get the event prefix */
if (of_property_read_string(node, "events-prefix", &prefix)) if (of_property_read_string(node, "events-prefix", &prefix)) {
of_node_put(pmu_events);
return 0; return 0;
}
/* Get a global unit and scale data if available */ /* Get a global unit and scale data if available */
if (of_property_read_string(node, "scale", &g_scale)) if (of_property_read_string(node, "scale", &g_scale))
...@@ -255,8 +257,10 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu) ...@@ -255,8 +257,10 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
/* Allocate memory for the events */ /* Allocate memory for the events */
pmu->events = kcalloc(ct, sizeof(struct imc_events), GFP_KERNEL); pmu->events = kcalloc(ct, sizeof(struct imc_events), GFP_KERNEL);
if (!pmu->events) if (!pmu->events) {
of_node_put(pmu_events);
return -ENOMEM; return -ENOMEM;
}
ct = 0; ct = 0;
/* Parse the events and update the struct */ /* Parse the events and update the struct */
...@@ -266,6 +270,8 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu) ...@@ -266,6 +270,8 @@ static int update_events_in_group(struct device_node *node, struct imc_pmu *pmu)
ct++; ct++;
} }
of_node_put(pmu_events);
/* Allocate memory for attribute group */ /* Allocate memory for attribute group */
attr_group = kzalloc(sizeof(*attr_group), GFP_KERNEL); attr_group = kzalloc(sizeof(*attr_group), GFP_KERNEL);
if (!attr_group) { if (!attr_group) {
......
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