On Thu, Nov 05, 2026 at 02:38:08PM +0000, Lee Jones wrote: > omap->pdata->get_pwm_status() returns a signed int that can be a > negative error code on runtime PM failure or invalid timer cookie. > pwm_omap_dmtimer_is_enabled() and pwm_omap_dmtimer_polarity() store the > return value in an unsigned u32 and test OMAP_TIMER_CTRL_ST (BIT(0)) and > OMAP_TIMER_CTRL_SCPWM (BIT(7)), misinterpreting negative error codes > (such as -EINVAL or -EACCES) as an enabled or inverted timer. > > Store the return value in a signed int and check for negative error > codes before testing register bits. > > Fixes: 6b28fb6f3ca3 ("pwm: omap-dmtimer: Implement .apply callback") > Closes: https://sashiko.dev/#/bug/linux-f4782faa-466d-43a8-85d8-6d6181ee2243 > Cc: stable@vger.kernel.org > Signed-off-by: Lee Jones > --- > drivers/pwm/pwm-omap-dmtimer.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c > index 51830a87275c..1e4d8b9e224f 100644 > --- a/drivers/pwm/pwm-omap-dmtimer.c > +++ b/drivers/pwm/pwm-omap-dmtimer.c > @@ -111,9 +111,11 @@ static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap) > */ > static bool pwm_omap_dmtimer_is_enabled(struct pwm_omap_dmtimer_chip *omap) > { > - u32 status; > + int status; > > status = omap->pdata->get_pwm_status(omap->dm_timer); > + if (status < 0) > + return false; > > return !!(status & OMAP_TIMER_CTRL_ST); > } > @@ -126,9 +128,11 @@ static bool pwm_omap_dmtimer_is_enabled(struct pwm_omap_dmtimer_chip *omap) > */ > static int pwm_omap_dmtimer_polarity(struct pwm_omap_dmtimer_chip *omap) > { > - u32 status; > + int status; > > status = omap->pdata->get_pwm_status(omap->dm_timer); > + if (status < 0) > + return PWM_POLARITY_NORMAL; This looks incomplete. The function is used in pwm_omap_dmtimer_apply() as follows: if (pwm_omap_dmtimer_polarity(omap) != state->polarity) pwm_omap_dmtimer_set_polarity(chip, pwm, state->polarity); IMHO if there is a problem with reading out the current polarity apply should fail. With the current approach the polarity setting might just be ignored. The case above is a bit similar, but I think there it's less likely that strange things happen. Best regards Uwe