Linux driver-core infrastructure
 help / color / mirror / Atom feed
* [PATCH] driver core: platform: Check for NULL name in platform_get_resource_byname
@ 2026-11-19  0:18 linux
  0 siblings, 0 replies; only message in thread
From: linux @ 2026-11-19  0:18 UTC (permalink / raw)
  To: dave, gregkh, rafael, dakr, johan; +Cc: driver-core, Dr. David Alan Gilbert

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19  0:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  0:18 [PATCH] driver core: platform: Check for NULL name in platform_get_resource_byname linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox