From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Joachim Eastwood <manabian@gmail.com>,
NeilBrown <neil@brown.name>,
Grant Erickson <marathon96@gmail.com>,
Thierry Reding <thierry.reding@gmail.com>,
Lokesh Vutla <lokeshvutla@ti.com>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 6/8] pwm: omap-dmtimer: Handle negative error codes from get_pwm_status()
Date: Fri, 20 Nov 2026 12:57:20 +0100 [thread overview]
Message-ID: <awA06PJuX4-Imck4@monoceros> (raw)
In-Reply-To: <20261105143847.2559586-7-lee@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2381 bytes --]
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 <lee@kernel.org>
> ---
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-11-20 11:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261105143847.2559586-1-lee@kernel.org>
2026-11-05 14:38 ` [PATCH 1/8] pwm: tegra: Prevent 32-bit period truncation and division by zero Lee Jones
2026-11-05 15:46 ` Uwe Kleine-König
2026-11-18 17:16 ` Lee Jones
2026-11-19 14:44 ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 2/8] pwm: mxs: Return early when disabling and fix error-path clock leak Lee Jones
2026-11-05 16:50 ` Frank Li
2026-11-20 12:12 ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 3/8] pwm: loongson: Fix 32-bit control register truncation in pwm_loongson_set_polarity() Lee Jones
2026-11-05 14:38 ` [PATCH 4/8] pwm: axi-pwmgen: Enable clocks before accessing hardware registers in probe() Lee Jones
2026-11-05 15:48 ` Uwe Kleine-König
2026-11-05 18:26 ` Lee Jones
2026-11-05 18:26 ` Lee Jones
2026-11-06 13:01 ` Nuno Sá
2026-11-05 14:38 ` [PATCH 5/8] pwm: fsl-ftm: Enable ipg_clk around regcache_sync() during resume Lee Jones
2026-11-20 12:02 ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 6/8] pwm: omap-dmtimer: Handle negative error codes from get_pwm_status() Lee Jones
2026-11-20 11:57 ` Uwe Kleine-König [this message]
2026-11-05 14:38 ` [PATCH 7/8] pwm: tiehrpwm: Enable runtime PM before registering PWM chip Lee Jones
2026-11-20 12:06 ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 8/8] pwm: img: Unregister PWM chip before disabling runtime PM and clocks Lee Jones
2026-11-20 12:10 ` Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awA06PJuX4-Imck4@monoceros \
--to=ukleinek@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=lokeshvutla@ti.com \
--cc=manabian@gmail.com \
--cc=marathon96@gmail.com \
--cc=neil.armstrong@linaro.org \
--cc=neil@brown.name \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox