[PATCH] leds: ns2: add missing check for fwnode_property_read_u32_array

From: Chen Ni
Date: Thu Jul 25 2024 - 04:19:21 EST


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@xxxxxxxxxxx>
---
drivers/leds/leds-ns2.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

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);

--
2.25.1