From: sashiko-bot@kernel.org
To: "Muhammad Bilal" <meatuni001@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/nouveau/iccsense: fix memory leak in nvkm_iccsense_oneinit
Date: Mon, 03 Aug 2026 22:05:39 +0000 [thread overview]
Message-ID: <20260803220540.436A91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803215022.172201-1-meatuni001@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Branching on uninitialized memory triggers undefined behavior and potential out-of-bounds heap read.
--
--- Patch [1]: [PATCH] drm/nouveau/iccsense: fix memory leak in nvkm_iccsense_oneinit ---
commit db41910973f19f5f6b73007149784b3d74245e81
Author: Muhammad Bilal <meatuni001@gmail.com>
drm/nouveau/iccsense: fix memory leak in nvkm_iccsense_oneinit
This commit fixes a memory leak in nvkm_iccsense_oneinit() where the
stbl.rail array allocated by nvbios_iccsense_parse() was never freed.
The array is now correctly freed in a common exit path that handles both
success and error conditions.
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 3ccdbbe2fad09..6bfe4913dcb66 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -239,6 +239,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> return 0;
>
> iccsense->data_valid = true;
> + ret = 0;
> for (i = 0; i < stbl.nr_entry; ++i) {
> struct pwr_rail_t *pwr_rail = &stbl.rail[i];
[Severity: High]
This is a pre-existing issue, but could this read uninitialized memory?
In drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c, the function
nvbios_iccsense_parse() allocates the rail array using kmalloc_objs(),
which does not zero memory:
iccsense->rail = kmalloc_objs(struct pwr_rail_t, cnt);
Inside its parsing loop, if nvbios_extdev_parse() fails, it skips
initialization of the remaining fields:
if (nvbios_extdev_parse(bios, rail->extdev_id, &extdev))
continue;
This leaves rail->resistor_count and rail->resistors uninitialized.
Then, back here in nvkm_iccsense_oneinit(), we read
pwr_rail->resistor_count:
if (pwr_rail->mode != 1 || !pwr_rail->resistor_count)
continue;
If the uninitialized resistor_count happens to be non-zero, this loop
could execute using that garbage value and access memory out of bounds:
for (r = 0; r < pwr_rail->resistor_count; ++r) {
...
struct pwr_rail_resistor_t *res = &pwr_rail->resistors[r];
Should nvbios_iccsense_parse() zero the allocated memory to prevent this?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803215022.172201-1-meatuni001@gmail.com?part=1
prev parent reply other threads:[~2026-08-03 22:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 21:50 [PATCH] drm/nouveau/iccsense: fix memory leak in nvkm_iccsense_oneinit Muhammad Bilal
2026-08-03 22:05 ` 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=20260803220540.436A91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=meatuni001@gmail.com \
--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