mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
perf python: Fix memory leak in pyrf__metrics_cb
In pyrf__metrics_cb, PyDict_SetItem does not steal the reference of the
key and value, so they need to be decref'ed after successful insertion
to avoid memory leaks.
Fixes: 47b3e95728 ("perf python: Add metrics function")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
cb45ede21d
commit
1ec13016ba
|
|
@ -3575,6 +3575,8 @@ static int pyrf__metrics_cb(const struct pmu_metric *pm,
|
|||
Py_XDECREF(dict);
|
||||
return -ENOMEM;
|
||||
}
|
||||
Py_DECREF(key);
|
||||
Py_DECREF(value);
|
||||
|
||||
if (!add_to_dict(dict, "MetricName", pm->metric_name) ||
|
||||
!add_to_dict(dict, "PMU", pm->pmu) ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user