Skip to contentSkip to conversation

driver core: platform: Check for NULL name in platform_get_resource_byname

PATCH New [email protected] 1 participant 1 message Nov 19 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: platform: Check for NULL name in platform_get_resource_byname

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 drivers/base/platform.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/platform.c +3 -0
index 3593d45f4a7a..5ef1cf79e57b 100644
@@ -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];
 
Signature · 1 line
2.56.1