[PATCH 1/2] hwmon: tmp421: check error when loading label from dt
From: Bruno Thomsen
Date: Tue Nov 11 2025 - 09:44:30 EST
Add error checking when loading temperature channel label defined
in device tree. Handling of error from of_property_read_string()
is inspired by lm90 driver and therefor contain same error string.
Signed-off-by: Bruno Thomsen <bruno.thomsen@xxxxxxxxx>
---
drivers/hwmon/tmp421.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
index 9537727aad9a..1eded169e843 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -381,7 +381,11 @@ static int tmp421_probe_child_from_dt(struct i2c_client *client,
return -EINVAL;
}
- of_property_read_string(child, "label", &data->channel[i].label);
+ err = of_property_read_string(child, "label", &data->channel[i].label);
+ if (err == -ENODATA || err == -EILSEQ) {
+ dev_err(dev, "invalid label property in %pOFn\n", child);
+ return err;
+ }
if (data->channel[i].label)
data->temp_config[i] |= HWMON_T_LABEL;
base-commit: 284922f4c563aa3a8558a00f2a05722133237fe8
--
2.51.1