Linux driver-core infrastructure
 help / color / mirror / Atom feed
From: linux@treblig.org
To: dave@treblig.org, gregkh@linuxfoundation.org, rafael@kernel.org,
	dakr@kernel.org, johan@kernel.org
Cc: driver-core@lists.linux.dev,
	"Dr. David Alan Gilbert" <linux@treblig.org>
Subject: [PATCH] driver core: platform: Check for NULL name in platform_get_resource_byname
Date: Thu, 19 Nov 2026 00:18:20 +0000	[thread overview]
Message-ID: <20261119001820.168018-1-linux@treblig.org> (raw)

From: "Dr. David Alan Gilbert" <linux@treblig.org>

Drivers are calling platform_get_resource_byname() with a name string
derived from a DT.  If that's a DT that's broken without the field
that should land in the name field, a NULL is passed and it OOPSs
in the strcmp.  Check for a NULL name and return NULL; turning
a crash into one broken device.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 drivers/base/platform.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3593d45f4a7a..5ef1cf79e57b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -464,6 +464,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
 {
 	u32 i;
 
+	if (unlikely(!name))
+		return NULL;
+
 	for (i = 0; i < dev->num_resources; i++) {
 		struct resource *r = &dev->resource[i];
 
-- 
2.56.1


                 reply	other threads:[~2026-11-19  0:18 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=20261119001820.168018-1-linux@treblig.org \
    --to=linux@treblig.org \
    --cc=dakr@kernel.org \
    --cc=dave@treblig.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=rafael@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