[PATCH 4/8] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent

Sudeep Holla
2025-10-17T13:24:14Z

scmi_debugfs_common_setup() previously called fwnode_property_read_string()
without checking its return value, which could leave c_ptr uninitialized
and lead to kstrdup() on garbage.

Handle the failure case and use the ACPI HID via acpi_device_hid()
using ACPI_COMPANION(dev) as a fallback for ACPI-described systems.
This ensures dbg->type is either a valid string or we hit the existing
error path cleanly.

This improves robustness on non-DT platforms where "compatible" is not
present.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index bc5fea11b5db..148b9a13d43f 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2988,8 +2988,9 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
return NULL;
}

- fwnode_property_read_string(dev_fwnode(info->dev), "compatible",
- &c_ptr);
+ if (fwnode_property_read_string(dev_fwnode(info->dev), "compatible",
+ &c_ptr))
+ c_ptr = acpi_device_hid(ACPI_COMPANION(info->dev)) ?: "unknown";
dbg->type = kstrdup(c_ptr, GFP_KERNEL);
if (!dbg->type) {
kfree(dbg->name);

--
2.34.1