summaryrefslogtreecommitdiff
path: root/tools/perf/util/python.c
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-08-09 00:14:49 -0700
committerNamhyung Kim <namhyung@kernel.org>2026-08-09 21:58:11 -0700
commitb365402cd5ea9e932b1458ee966d2258105da75d (patch)
tree30588dac8f91b70071bfcec0b7755ef7146b5f8d /tools/perf/util/python.c
parent0b274050c4d427828595c12c2e4e53d98612b4f9 (diff)
perf python: Zero initialize perf_data in pyrf_data__init
Replace path clearing with memset so the entire struct is zeroed, preventing uninitialized fields from causing errors later. Fixes: 4cd0142f7dec ("perf python: Add wrapper for perf_data file abstraction") Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/python.c')
-rw-r--r--tools/perf/util/python.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 848912401c4f..c70b151428f7 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -3,6 +3,7 @@
#include <Python.h>
#include <inttypes.h>
+#include <string.h>
#include <linux/err.h>
#include <poll.h>
@@ -3627,7 +3628,7 @@ static int pyrf_data__init(struct pyrf_data *pdata, PyObject *args, PyObject *kw
if (pdata->data.open)
perf_data__close(&pdata->data);
free((char *)pdata->data.path);
- pdata->data.path = NULL;
+ memset(&pdata->data, 0, sizeof(pdata->data));
if (fd != -1) {
struct stat st;