public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 6.9-stable tree
@ 2024-06-24 16:47 gregkh
  2024-06-25  7:54 ` [PATCH 6.9.y and older] pwm: stm32: Refuse too small period requests Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2024-06-24 16:47 UTC (permalink / raw)
  To: u.kleine-koenig, tgamblin, ukleinek; +Cc: stable


The patch below does not apply to the 6.9-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.9.y
git checkout FETCH_HEAD
git cherry-pick -x c45fcf46ca2368dafe7e5c513a711a6f0f974308
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2024062455-green-reach-3f21@gregkh' --subject-prefix 'PATCH 6.9.y' HEAD^..

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From c45fcf46ca2368dafe7e5c513a711a6f0f974308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@baylibre.com>
Date: Fri, 21 Jun 2024 16:37:12 +0200
Subject: [PATCH] pwm: stm32: Refuse too small period requests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If period_ns is small, prd might well become 0. Catch that case because
otherwise with

	regmap_write(priv->regmap, TIM_ARR, prd - 1);

a few lines down quite a big period is configured.

Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm")
Cc: stable@vger.kernel.org
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/b86f62f099983646f97eeb6bfc0117bb2d0c340d.1718979150.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index a2f231d13a9f..3e7b2a8e34e7 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -337,6 +337,8 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch,
 
 	prd = mul_u64_u64_div_u64(period_ns, clk_get_rate(priv->clk),
 				  (u64)NSEC_PER_SEC * (prescaler + 1));
+	if (!prd)
+		return -EINVAL;
 
 	/*
 	 * All channels share the same prescaler and counter so when two


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 6.9.y and older] pwm: stm32: Refuse too small period requests
  2024-06-24 16:47 FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 6.9-stable tree gregkh
@ 2024-06-25  7:54 ` Uwe Kleine-König
  2024-07-02  9:08   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2024-06-25  7:54 UTC (permalink / raw)
  To: stable; +Cc: Trevor Gamblin, Uwe Kleine-König

If period_ns is small, prd might well become 0. Catch that case because
otherwise with

	regmap_write(priv->regmap, TIM_ARR, prd - 1);

a few lines down quite a big period is configured.

Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm")
Cc: stable@vger.kernel.org
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/b86f62f099983646f97eeb6bfc0117bb2d0c340d.1718979150.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
(cherry picked from commit c45fcf46ca2368dafe7e5c513a711a6f0f974308)
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
Hello,

this is a backport of c45fcf46ca2368dafe7e5c513a711a6f0f974308 to 6.9.y.
It applies fine to 4.19.y, 5.4.y, 5.10.y, 5.15.y, 6.1.y and 6.6.y, too.
Please apply accordingly.

Best regards
Uwe

 drivers/pwm/pwm-stm32.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 0c028d17c075..9f07d50aba2a 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -329,6 +329,9 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch,
 
 	prd = div;
 
+	if (!prd)
+		return -EINVAL;
+
 	if (prescaler > MAX_TIM_PSC)
 		return -EINVAL;
 

base-commit: 9c5a72fbc90d829ffb761da64a73c23cd4e0503f
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 6.9.y and older] pwm: stm32: Refuse too small period requests
  2024-06-25  7:54 ` [PATCH 6.9.y and older] pwm: stm32: Refuse too small period requests Uwe Kleine-König
@ 2024-07-02  9:08   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-07-02  9:08 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: stable, Trevor Gamblin, Uwe Kleine-König

On Tue, Jun 25, 2024 at 09:54:05AM +0200, Uwe Kleine-König wrote:
> If period_ns is small, prd might well become 0. Catch that case because
> otherwise with
> 
> 	regmap_write(priv->regmap, TIM_ARR, prd - 1);
> 
> a few lines down quite a big period is configured.
> 
> Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm")
> Cc: stable@vger.kernel.org
> Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> Link: https://lore.kernel.org/r/b86f62f099983646f97eeb6bfc0117bb2d0c340d.1718979150.git.u.kleine-koenig@baylibre.com
> Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
> (cherry picked from commit c45fcf46ca2368dafe7e5c513a711a6f0f974308)
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> Hello,
> 
> this is a backport of c45fcf46ca2368dafe7e5c513a711a6f0f974308 to 6.9.y.
> It applies fine to 4.19.y, 5.4.y, 5.10.y, 5.15.y, 6.1.y and 6.6.y, too.
> Please apply accordingly.
> 

Now queued up, thanks

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-02  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-24 16:47 FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 6.9-stable tree gregkh
2024-06-25  7:54 ` [PATCH 6.9.y and older] pwm: stm32: Refuse too small period requests Uwe Kleine-König
2024-07-02  9:08   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox