All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Alexey Charkov <alchark@flipper.net>,
	Rajendra Nayak <rnayak@ti.com>,
	Corentin Labbe <clabbe@baylibre.com>,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 7/8] regulator: of: Guard against NULL device_node in of_regulator_bulk_get_all()
Date: Fri, 27 Nov 2026 18:35:47 +0000	[thread overview]
Message-ID: <20261127183624.3341010-8-lee@kernel.org> (raw)
In-Reply-To: <20261127183624.3341010-1-lee@kernel.org>

of_regulator_bulk_get_all() passes np straight into
for_each_property_of_node(), which dereferences np->properties without
checking for NULL.  Callers passing dev_of_node(dev) on non-DT devices
therefore crash with a NULL pointer dereference.

Return 0 immediately when np is NULL, matching the !CONFIG_OF stub and
the empty-supply case.

Fixes: 27b9ecc7a9ba ("regulator: Add of_regulator_bulk_get_all")
Closes: https://sashiko.dev/#/bug/linux-626e95b1-6ae0-438b-95b4-b7a96b2fd27e
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/regulator/of_regulator.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 81d4f8b6458b..0a316ccefaa9 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -947,6 +947,9 @@ int of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
 	char *names;
 	int i, n = 0, ret;
 
+	if (!np)
+		return 0;
+
 	/*
 	 * first pass: get numbers of xxx-supply and the room their names take
 	 * second pass: fill consumers
-- 
2.56.1.839.g22a8290db9-goog


  parent reply	other threads:[~2026-11-27 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 18:35 [PATCH 0/8] regulator: Fix locking, OOB read, lifetime, and global state bugs (batch 2) Lee Jones
2026-11-27 18:35 ` [PATCH 1/8] regulator: core: Defer supply cleanup and unregister event forwarding on error Lee Jones
2026-11-30 23:48   ` Doug Anderson
2026-12-01 11:02     ` Lee Jones
2026-11-27 18:35 ` [PATCH 2/8] regulator: max8907: Duplicate of_regulator_match table per device Lee Jones
2026-11-27 18:35 ` [PATCH 3/8] regulator: tps6594-regulator: Use dedicated handler for external regulator IRQs Lee Jones
2026-11-27 18:35 ` [PATCH 4/8] regulator: tps65910: Fix OOB read and bit shift in external sleep config Lee Jones
2026-11-27 18:35 ` [PATCH 5/8] regulator: tps6594-regulator: Bind IRQ resources to child platform device Lee Jones
2026-11-27 18:35 ` [PATCH 6/8] regulator: core: Respect is_locked when disabling supply on enable failure Lee Jones
2026-11-27 18:35 ` Lee Jones [this message]
2026-11-27 18:35 ` [PATCH 8/8] regulator: aat2870: Duplicate regulator data per device Lee Jones

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=20261127183624.3341010-8-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=alchark@flipper.net \
    --cc=broonie@kernel.org \
    --cc=clabbe@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rnayak@ti.com \
    --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 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.