Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v10 05/10] block: partitions: of: Attach partition fwnode to the block device
Date: Fri, 07 Aug 2026 14:39:25 +0000	[thread overview]
Message-ID: <20260807143926.0C5731F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260806-block-as-nvmem-v10-5-be598b2a5606@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] In `validate_of_partition` and `add_of_partition`, if the 'reg' property is not found, `of_get_property` returns `NULL` and leaves `len` uninitialized. This uninitialized `len` is then used in a length check, which may coincidentally pass, leading to a NULL pointer dereference.
--

--- Patch [5]: [PATCH v10 05/10] block: partitions: of: Attach partition fwnode to the block device ---
commit 84a9bb090d9a515321ec327f495f887813824601
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>

block: partitions: of: Attach partition fwnode to the block device

This patch carries the partition's device tree node through the OF parser
and attaches it to the block device. This mirrors the whole-disk case and
allows consumers to look up per-partition properties in the device tree.

> 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));
> +

[Severity: High]
This is a pre-existing issue, but can this code path trigger a NULL
pointer dereference if the "reg" property is missing in the device tree?

Looking earlier in add_of_partition(), it calls of_get_property() for the
"reg" property:

	const __be32 *reg = of_get_property(np, "reg", &len);
	int a_cells = of_n_addr_cells(np);
	int s_cells = of_n_size_cells(np);

	/* Convert bytes to sector size */
	u64 offset = of_read_number(reg, a_cells) / SECTOR_SIZE;

If the "reg" property is not found, of_get_property() returns NULL and
leaves the len variable uninitialized.

The same pattern exists in validate_of_partition(). If the uninitialized
len variable happens to match the expected length, validate_of_partition()
could bypass its check, leading to of_read_number() unconditionally
dereferencing a NULL reg pointer.

Should there be an explicit check for reg != NULL before attempting to
read the offset?

>  	seq_buf_printf(&state->pp_buf, "(%s)", info->volname);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-block-as-nvmem-v10-0-be598b2a5606@oss.qualcomm.com?part=5

  reply	other threads:[~2026-08-07 14:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 14:38 [PATCH v10 00/10] Support for block device NVMEM providers Loic Poulain
2026-08-06 14:38 ` [PATCH v10 01/10] dt-bindings: mmc: Document fixed-layout NVMEM provider support Loic Poulain
2026-08-06 14:38 ` [PATCH v10 02/10] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-08-06 14:38 ` [PATCH v10 03/10] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-08-07 14:39   ` sashiko-bot
2026-08-06 14:38 ` [PATCH v10 04/10] nvmem: layouts: Support fixed-layout as the nvmem device node itself Loic Poulain
2026-08-07 14:39   ` sashiko-bot
2026-08-06 14:38 ` [PATCH v10 05/10] block: partitions: of: Attach partition fwnode to the block device Loic Poulain
2026-08-07 14:39   ` sashiko-bot [this message]
2026-08-06 14:38 ` [PATCH v10 06/10] block: implement NVMEM provider Loic Poulain
2026-08-07 14:39   ` sashiko-bot
2026-08-06 14:38 ` [PATCH v10 07/10] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-08-06 14:38 ` [PATCH v10 08/10] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-08-07 14:39   ` sashiko-bot
2026-08-06 14:38 ` [PATCH v10 09/10] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-08-06 14:38 ` [PATCH v10 10/10] arm64: dts: qcom: arduino-imola: Add NVMEM layout for WiFi/BT Loic Poulain

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=20260807143926.0C5731F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox