[PATCH] rtc: isl12022: Add missing check for device_property_read_u32_array

Chen Ni posted 1 patch 1 week, 3 days ago
drivers/rtc/rtc-isl12022.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] rtc: isl12022: Add missing check for device_property_read_u32_array
Posted by Chen Ni 1 week, 3 days ago
Add check for the return value of device_property_read_u32_array() and
log a warning message if it fails in order to catch the error.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/rtc/rtc-isl12022.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c
index 5fc52dc64213..6f66ec4a9948 100644
--- a/drivers/rtc/rtc-isl12022.c
+++ b/drivers/rtc/rtc-isl12022.c
@@ -517,8 +517,10 @@ static void isl12022_set_trip_levels(struct device *dev)
 	int ret, i, j, x[2];
 	u8 val, mask;
 
-	device_property_read_u32_array(dev, "isil,battery-trip-levels-microvolt",
-				       levels, 2);
+	ret = device_property_read_u32_array(dev, "isil,battery-trip-levels-microvolt",
+					     levels, 2);
+	if (ret)
+		dev_warn(dev, "failed to read battery-trip-levels-microvolt: %d\n", ret);
 
 	for (i = 0; i < 2; i++) {
 		for (j = 0; j < ARRAY_SIZE(trip_levels[i]) - 1; j++) {
-- 
2.25.1
Re: [PATCH] rtc: isl12022: Add missing check for device_property_read_u32_array
Posted by Markus Elfring 1 week, 3 days ago
> Add check for the return value of device_property_read_u32_array() and
> log a warning message if it fails in order to catch the error.

* Were any source code analysis tools involved here?

* Did anything hinder to add any tags (like “Fixes” and “Cc”) accordingly?


Regards,
Markus