Linux block layer
 help / color / mirror / Atom feed
From: Loic Poulain <loic.poulain@oss.qualcomm.com>
To: Jens Axboe <axboe@kernel.dk>, Christian Marangi <ansuelsmth@gmail.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Loic Poulain <loic.poulain@oss.qualcomm.com>
Subject: [PATCH] block: partitions: of: Fix NULL dereference on partition without reg
Date: Fri, 17 Jul 2026 16:26:33 +0200	[thread overview]
Message-ID: <20260717-partition-null-v1-1-47984cff2d7e@oss.qualcomm.com> (raw)

A child node of a fixed-partitions node may lack a reg property, either
because it is malformed or because it is not a partition entry at all.
In that case of_get_property() returns NULL to reg, which is then
dereferenced without proper checking.

Fixes: 2e3a191e89f9 ("block: add support for partition table defined in OF")
Cc: stable@vger.kernel.org
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
 block/partitions/of.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/partitions/of.c b/block/partitions/of.c
index 53664ea06b6540e3d1155141adaafac7286f2d21..dab36513eba336344c9558d486a8915624b0fca8 100644
--- a/block/partitions/of.c
+++ b/block/partitions/of.c
@@ -15,6 +15,9 @@ static int validate_of_partition(struct device_node *np, int slot)
 	int a_cells = of_n_addr_cells(np);
 	int s_cells = of_n_size_cells(np);
 
+	if (!reg)
+		return -EINVAL;
+
 	/* Make sure reg len match the expected addr and size cells */
 	if (len / sizeof(*reg) != a_cells + s_cells)
 		return -EINVAL;

---
base-commit: fce2dfa773ced15f27dd27cd0b482a7473cdcf2a
change-id: 20260717-partition-null-b05e2c956ee7

Best regards,
-- 
Loic Poulain <loic.poulain@oss.qualcomm.com>


                 reply	other threads:[~2026-07-17 14:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260717-partition-null-v1-1-47984cff2d7e@oss.qualcomm.com \
    --to=loic.poulain@oss.qualcomm.com \
    --cc=ansuelsmth@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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