pwm_adp5585_get_state() reads the PWM configuration register to find out whether the output is enabled: regmap_read(regmap, info->pwm_cfg, &val); state->enabled = !!(val & ADP5585_PWM_EN); The return value of regmap_read() is ignored. When the register access fails, regmap_read() returns early without writing to *val, so the uninitialized stack variable is used to derive .enabled. As the function still returns 0, pwm_request() caches the bogus state in pwm->state, so a failed read is silently reported as a valid state instead of an error. The two preceding regmap_bulk_read() calls do propagate their errors, which makes this one an oversight. Return the error from regmap_read() instead. pwm_apply_state() and pwm_get_state_hw() both handle a failing .get_state(), so propagating the error is what the PWM core expects. Fixes: e9b503879fd2 ("pwm: adp5585: Add Analog Devices ADP5585 support") Cc: stable@vger.kernel.org Signed-off-by: Lin Huiyi --- drivers/pwm/pwm-adp5585.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-adp5585.c b/drivers/pwm/pwm-adp5585.c index 9a1dbba75b..5d6187255d 100644 --- a/drivers/pwm/pwm-adp5585.c +++ b/drivers/pwm/pwm-adp5585.c @@ -143,7 +143,9 @@ static int pwm_adp5585_get_state(struct pwm_chip *chip, state->polarity = PWM_POLARITY_NORMAL; - regmap_read(regmap, info->pwm_cfg, &val); + ret = regmap_read(regmap, info->pwm_cfg, &val); + if (ret) + return ret; state->enabled = !!(val & ADP5585_PWM_EN); return 0; -- 2.56.1