From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBC7A330B17; Fri, 17 Oct 2025 15:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760716290; cv=none; b=j/IXlCxbhBFEVtOw5EG2CyJ07JWEytj+nD1OcfyjDAweMD8ekAb9HgnPIG/z6VWek6pagivyG3WhzsipKelk4VpPA1QDc+mCCnOJCTB2/nrKOiFohETLt7cN1Qdr5+8PCdvvPPnzm1/OUBgwZBTP0eQNEEX8rPaatNLysCBDxok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760716290; c=relaxed/simple; bh=g7hlPvH7xbb9XhlN4E6Hr8EPKkjTwdT89ctVOP7qRK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X5llRRgqr3uptQU1ESYcib2Yf1KH/3kLHA99jYQTqlgYCdp8As4TGjuj+gDw+huyZWiCwXe5gS7JMIr/96pCPL5UIJ/+ez2C4xubvuUDXNje3NDufdZBA7d196jRfg2x3/uWCUHmwIXP8xLN8gZcqHPziTMAhst6XnkhZCQKG2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=O960Bc1d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="O960Bc1d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E489BC4CEE7; Fri, 17 Oct 2025 15:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760716290; bh=g7hlPvH7xbb9XhlN4E6Hr8EPKkjTwdT89ctVOP7qRK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O960Bc1dlGBJzr/ERVmLQy9sblalq621NMGkRqWKYZw2Mdn3cmKzrEmyqEFEBXwdy Ic1aAtcLzdsMEXb4WReazhmGV7avC39Lkhp0AFuBccPEOaRd+YD3bAhVNZPwCX2GO0 f4dxexzBek1Dt/TlJdL5lpiFCV2con8dwk734r1A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alok Tiwari , Stephen Boyd , Sasha Levin Subject: [PATCH 5.15 138/276] clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver Date: Fri, 17 Oct 2025 16:53:51 +0200 Message-ID: <20251017145147.520814463@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145142.382145055@linuxfoundation.org> References: <20251017145142.382145055@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alok Tiwari [ Upstream commit 1624dead9a4d288a594fdf19735ebfe4bb567cb8 ] 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 [sboyd@kernel.org: 'm' is unsigned so remove < condition] Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- 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 44e07a3c253b9..ab8741fe57c99 100644 --- a/drivers/clk/nxp/clk-lpc18xx-cgu.c +++ b/drivers/clk/nxp/clk-lpc18xx-cgu.c @@ -385,7 +385,7 @@ static int lpc18xx_pll0_determine_rate(struct clk_hw *hw, } m = DIV_ROUND_UP_ULL(req->best_parent_rate, req->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__, req->rate); return -EINVAL; } @@ -408,7 +408,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.51.0