From: sashiko-bot@kernel.org
To: "Chen Pei" <cp0613@linux.alibaba.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3] perf riscv: Add perf_regs_load and enable the dwarf unwind test
Date: Wed, 16 Sep 2026 09:00:08 +0000 [thread overview]
Message-ID: <20260916090009.6B3C01F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916084626.1166-1-cp0613@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf: NULL pointer dereference in test__arch_unwind_sample() on OOM
--
commit 5845b516a9f1970f694021ec56b60a02bd3f3b49
Author: Chen Pei <cp0613@linux.alibaba.com>
perf riscv: Add perf_regs_load and enable the dwarf unwind test
This commit adds perf_regs_load() and an architecture-specific unwind
sample helper for RISC-V. It also wires RISC-V into the test gates to
enable the DWARF unwind test on this architecture.
> diff --git a/tools/perf/arch/riscv/tests/dwarf-unwind.c b/tools/perf/arch/riscv/tests/dwarf-unwind.c
> new file mode 100644
> index 0000000000000..fe0c32ea0e05a
> --- /dev/null
> +++ b/tools/perf/arch/riscv/tests/dwarf-unwind.c
[ ... ]
> +int test__arch_unwind_sample(struct perf_sample *sample,
> + struct thread *thread)
> +{
> + struct regs_dump *regs = perf_sample__user_regs(sample);
> + u64 *buf;
> +
> + buf = calloc(PERF_REGS_MAX, sizeof(u64));
> + if (!buf) {
> + pr_debug("failed to allocate sample uregs data\n");
> + return -1;
> + }
> +
> + perf_regs_load(buf);
> + regs->abi = PERF_SAMPLE_REGS_ABI;
[Severity: Medium]
Is it possible for perf_sample__user_regs() to return a NULL pointer?
If memory allocation fails during perf_sample__user_regs(), it returns NULL.
Since the subsequent calloc() for buf may still succeed, could this lead to an
unconditional NULL pointer dereference when assigning regs->abi?
Would it be better to verify that regs is not NULL before attempting to
assign values to its fields?
> + regs->regs = buf;
> + regs->mask = PERF_REGS_MASK;
> +
> + return sample_ustack(sample, thread, buf);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916084626.1166-1-cp0613@linux.alibaba.com?part=1
prev parent reply other threads:[~2026-09-16 9:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 8:46 [PATCH v3] perf riscv: Add perf_regs_load and enable the dwarf unwind test Chen Pei
2026-09-16 9:00 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916090009.6B3C01F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cp0613@linux.alibaba.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox