public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver
@ 2025-07-06 20:11 Alok Tiwari
  2025-09-21 19:58 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Alok Tiwari @ 2025-07-06 20:11 UTC (permalink / raw)
  To: sboyd, vz, linux-clk
  Cc: alok.a.tiwari, darren.kenny, linux-kernel, linux-arm-kernel

The conditional check for the PLL0 multiplier 'm' used a logical AND
instead of OR, making the range check ineffective. This patch replaces
&& with || to correctly reject invalid values of 'm' that are either
less than or equal to 0 or greater than LPC18XX_PLL0_MSEL_MAX.

This ensures proper bounds checking during clk rate setting and rounding.

Fixes: b04e0b8fd544 ("clk: add lpc18xx cgu clk driver")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/clk/nxp/clk-lpc18xx-cgu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/nxp/clk-lpc18xx-cgu.c b/drivers/clk/nxp/clk-lpc18xx-cgu.c
index 81efa885069b2..7d8b2ed31abdf 100644
--- a/drivers/clk/nxp/clk-lpc18xx-cgu.c
+++ b/drivers/clk/nxp/clk-lpc18xx-cgu.c
@@ -381,7 +381,7 @@ static long lpc18xx_pll0_round_rate(struct clk_hw *hw, unsigned long rate,
 	}
 
 	m = DIV_ROUND_UP_ULL(*prate, rate * 2);
-	if (m <= 0 && m > LPC18XX_PLL0_MSEL_MAX) {
+	if (m <= 0 || m > LPC18XX_PLL0_MSEL_MAX) {
 		pr_warn("%s: unable to support rate %lu\n", __func__, rate);
 		return -EINVAL;
 	}
@@ -402,7 +402,7 @@ static int lpc18xx_pll0_set_rate(struct clk_hw *hw, unsigned long rate,
 	}
 
 	m = DIV_ROUND_UP_ULL(parent_rate, rate * 2);
-	if (m <= 0 && m > LPC18XX_PLL0_MSEL_MAX) {
+	if (m <= 0 || m > LPC18XX_PLL0_MSEL_MAX) {
 		pr_warn("%s: unable to support rate %lu\n", __func__, rate);
 		return -EINVAL;
 	}
-- 
2.46.0



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

* Re: [PATCH] clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver
  2025-07-06 20:11 [PATCH] clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver Alok Tiwari
@ 2025-09-21 19:58 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2025-09-21 19:58 UTC (permalink / raw)
  To: Alok Tiwari, linux-clk, vz
  Cc: alok.a.tiwari, darren.kenny, linux-kernel, linux-arm-kernel

Quoting Alok Tiwari (2025-07-06 13:11:55)
> The conditional check for the PLL0 multiplier 'm' used a logical AND
> instead of OR, making the range check ineffective. This patch replaces
> && with || to correctly reject invalid values of 'm' that are either
> less than or equal to 0 or greater than LPC18XX_PLL0_MSEL_MAX.
> 
> This ensures proper bounds checking during clk rate setting and rounding.
> 
> Fixes: b04e0b8fd544 ("clk: add lpc18xx cgu clk driver")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---

Applied to clk-next


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

end of thread, other threads:[~2025-09-21 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-06 20:11 [PATCH] clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver Alok Tiwari
2025-09-21 19:58 ` Stephen Boyd

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