Re: [PATCH v5 12/25] perf db-export: Remove evsel from struct export_sample
| Newsgroups | org.kernel.vger.linux-perf-users |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Memory leak of perf_sample dynamic resources on an error path in guest_session__inject_events. -- --- Patch [12]: [PATCH v5 12/25] perf db-export: Remove evsel from struct export_sample --- commit 02552ec2b6c1689ee30f03697d74752609caef8e Author: Ian Rogers <[email protected]> perf db-export: Remove evsel from struct export_sample As the sample contains the evsel avoid the duplication. Remove the evsel from db_export__sample as it can also read from the sample. > diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c > index a1f578c3a8d50..fdfd825c7ef48 100644 > --- a/tools/perf/util/db-export.c > +++ b/tools/perf/util/db-export.c [ ... ] > @@ -365,7 +364,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, > if (!machine) > return -1; > > - err = db_export__evsel(dbe, evsel); > + err = db_export__evsel(dbe, sample->evsel); > if (err) > return err; While reviewing the sample tracking changes in this series, I noticed a potential leak on an error path in guest_session__inject_events in tools/perf/builtin-inject.c: > if (sample->cpu != (u32)-1) { > if (sample->cpu >= gs->vcpu_cnt) { > pr_err("Guest event with unknown VCPU %u\n", > sample->cpu); > return -EINVAL; [Severity: Medium] Will this return statement bypass the perf_sample__exit cleanup code? A prior patch in this series added proper resource tracking and converted the other return statements in this loop to use break to ensure perf_sample__exit runs. It appears this specific error path still returns directly, which can leak dynamically allocated resources in perf_sample (such as user_regs and intr_regs) when processing an invalid guest perf.data file. > } > /* Change to host CPU instead of guest VCPU */ > sample->cpu = gs->vcpu[sample->cpu].cpu; > } -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12