Re: [PATCH] hwmon: (pwm-fan) Add missing check for device_property_read_u32_array
From: Guenter Roeck
Date: Thu Jan 29 2026 - 09:18:30 EST
On Wed, Jan 28, 2026 at 03:26:10PM +0800, Chen Ni wrote:
> Add check for the return value of device_property_read_u32_array() and
> return the error if it fails in order to catch the error.
>
> Signed-off-by: Chen Ni <nichen@xxxxxxxxxxx>
> ---
> drivers/hwmon/pwm-fan.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 37269db2de84..3535007f5c37 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -609,8 +609,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
> for (i = 0; i < ctx->tach_count; i++)
> ctx->pulses_per_revolution[i] = 2;
>
> - device_property_read_u32_array(dev, "pulses-per-revolution",
> - ctx->pulses_per_revolution, ctx->tach_count);
> + ret = device_property_read_u32_array(dev, "pulses-per-revolution",
> + ctx->pulses_per_revolution, ctx->tach_count);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Failed to read pulses-per-revolution\n");
NACK
This would defeat the purpose of setting the default a couple of lines above.
Guenter
> }
>
> channels = devm_kcalloc(dev, channel_count + 1,
> --
> 2.25.1
>
>