diff mbox series

leds: ns2: add missing check for fwnode_property_read_u32_array

Message ID 20240725081537.3247339-1-nichen@iscas.ac.cn
State New
Headers show
Series leds: ns2: add missing check for fwnode_property_read_u32_array | expand

Commit Message

Chen Ni July 25, 2024, 8:15 a.m. UTC
Add check for the return value of fwnode_property_read_u32_array() and
return the error if it fails in order to catch the error.

Fixes: 940cca1ab5d6 ("leds: ns2: convert to fwnode API")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/leds/leds-ns2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index f3010c472bbd..0713f7e9d1af 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -202,8 +202,12 @@  static int ns2_led_register(struct device *dev, struct fwnode_handle *node,
 	if (!modval)
 		return -ENOMEM;
 
-	fwnode_property_read_u32_array(node, "modes-map", (void *)modval,
-				       nmodes * 3);
+	ret = fwnode_property_read_u32_array(node, "modes-map", (void *)modval,
+					     nmodes * 3);
+	if (ret) {
+		dev_err(dev, "Missing modes-map property for %pfw\n", node);
+		return ret;
+	}
 
 	rwlock_init(&led->rw_lock);