From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v9 05/10] block: partitions: of: Attach partition fwnode to the block device
Date: Fri, 31 Jul 2026 16:01:21 +0000 [thread overview]
Message-ID: <20260731160121.9E4DC1F00ACA@smtp.kernel.org> (raw)
In-Reply-To: <20260730-block-as-nvmem-v9-5-f72935817dbf@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Fwnode reference leak in partition parsing error and skip paths.
Pre-existing issues:
- [High] Uninitialized stack variable `len` validation allows NULL pointer dereference when the 'reg' property is missing.
--
--- Patch [5]: [PATCH v9 05/10] block: partitions: of: Attach partition fwnode to the block device ---
commit a6e4cc997f016ffdca55d082b2ff10454aec24f8
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>
block: partitions: of: Attach partition fwnode to the block device
The OF partition parser reads offset, size and label from each
"fixed-partitions" child node but does not associate that node with the
resulting partition block device. As a result a partition has no
of_node, unlike the whole-disk device which gets its firmware node via
add_disk_fwnode().
> diff --git a/block/partitions/of.c b/block/partitions/of.c
> index 53664ea06b654..4fc7c80c407de 100644
> --- a/block/partitions/of.c
> +++ b/block/partitions/of.c
[ ... ]
> @@ -62,6 +63,8 @@ static void add_of_partition(struct parsed_partitions *state, int slot,
> partname = of_get_property(np, "name", &len);
> strscpy(info->volname, partname, sizeof(info->volname));
>
> + state->parts[slot].fwnode = fwnode_handle_get(of_fwnode_handle(np));
> +
> seq_buf_printf(&state->pp_buf, "(%s)", info->volname);
> }
[Severity: High]
Does this create a fwnode reference leak if the partitions are never
successfully added?
If blk_add_partitions() aborts early (such as for zoned block devices) or
skips a partition, it jumps to out_free_state and calls free_partitions().
This frees the parsed partitions array without dropping the unconsumed
fwnode references.
Also, if add_partition() fails before calling device_initialize():
block/partitions/core.c:add_partition() {
...
err = -ENOMEM;
bdev = bdev_alloc(disk, partno);
if (!bdev)
goto out_put_disk;
...
}
will it return an error without dropping the fwnode, since part_release()
will never be executed to clean it up?
[Severity: High]
This is a pre-existing issue, but can the uninitialized len variable cause a
NULL pointer dereference when parsing malformed device trees?
Looking at validate_of_partition() in the same file:
block/partitions/of.c:validate_of_partition() {
int len;
const __be32 *reg = of_get_property(np, "reg", &len);
...
}
If the 'reg' property is missing, of_get_property() returns NULL and leaves
the stack variable len uninitialized. If the uninitialized stack garbage in
len happens to satisfy the subsequent length check:
if (len / sizeof(*reg) != a_cells + s_cells)
it will proceed to evaluate:
offset = of_read_number(reg, a_cells);
Since reg is NULL, will this result in a kernel panic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-block-as-nvmem-v9-0-f72935817dbf@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-07-31 16:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 16:00 [PATCH v9 00/10] Support for block device NVMEM providers Loic Poulain
2026-07-30 16:00 ` [PATCH v9 01/10] dt-bindings: mmc: Document fixed-layout NVMEM provider support Loic Poulain
2026-07-30 17:30 ` Support for block device NVMEM providers bluez.test.bot
2026-07-31 8:39 ` [PATCH v9 01/10] dt-bindings: mmc: Document fixed-layout NVMEM provider support Bartosz Golaszewski
2026-07-31 16:01 ` sashiko-bot
2026-07-30 16:00 ` [PATCH v9 02/10] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-07-30 16:00 ` [PATCH v9 03/10] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-07-30 16:00 ` [PATCH v9 04/10] nvmem: layouts: Support fixed-layout as the nvmem device node itself Loic Poulain
2026-07-31 16:01 ` sashiko-bot
2026-07-30 16:00 ` [PATCH v9 05/10] block: partitions: of: Attach partition fwnode to the block device Loic Poulain
2026-07-31 8:40 ` Bartosz Golaszewski
2026-07-31 16:01 ` sashiko-bot [this message]
2026-07-30 16:00 ` [PATCH v9 06/10] block: implement NVMEM provider Loic Poulain
2026-07-31 16:01 ` sashiko-bot
2026-07-30 16:00 ` [PATCH v9 07/10] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-07-30 16:00 ` [PATCH v9 08/10] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-07-31 16:01 ` sashiko-bot
2026-07-30 16:00 ` [PATCH v9 09/10] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-07-30 16:00 ` [PATCH v9 10/10] arm64: dts: qcom: arduino-imola: Describe NVMEM layout for WiFi/BT addresses Loic Poulain
2026-07-31 16:01 ` sashiko-bot
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=20260731160121.9E4DC1F00ACA@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.