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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 25, 2024 at 04:15:37PM +0800, Chen Ni wrote:
> 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;
> +	}

Please use
  return dev_err_probe()

also maybe in other parts of the driver probe where
  dev_err();
  return ret;
is being done.

The device_for_each_child_node() can be changed to
device_for_each_child_node_scoped() and you can drop the fwnode_handle_put()
from
  if (ret) {
    fwnode_handle_put(child);
    return ret;
  }

Marek




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux