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 AD3A41F669E; Tue, 3 Dec 2024 14:36:10 +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=1733236570; cv=none; b=YCDoNOi5UFiruztkS201Z6X80p/yYIT5wKnf0tbdUE7vh4M4Yzu8E5kSMNQ3HZsat4m5gWoN2ATR91s72z0ZNZu1bW3bYC3Bc1+FpDn6GepRzxaenunWf5bYihhxB1PfluLZAIBEaRU1aZNrjUYW7IiWcbeEXgHLJfftnNsBLQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236570; c=relaxed/simple; bh=XbCaeUpmgzYDoIZ0PYspWPLSqdU71pcwvFR8nmH873E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IkTPUoYOJ1k2PKJrrdLqVBNmsWDRbaQ2D5aNfHWWErYWIY/PzCiRXxZNteutnDbi0pbtxjatnWIY51lcPThb+/029HhTb8xJNNvlRJBOa04ex67yhiLwafHUUWGi4PJSXuxVHosFL9apqtg8DR1InBFH+09FI+GurdoZpMAf4qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jGidVHdD; 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="jGidVHdD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BB29C4CECF; Tue, 3 Dec 2024 14:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733236570; bh=XbCaeUpmgzYDoIZ0PYspWPLSqdU71pcwvFR8nmH873E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGidVHdDff9+geLFuCcWOp5bJZRuP4xtArEq1eofrFKy4TqmnXY5cwevzcBRLJJLp LOtKB47i3DLZQTWWD/ik1JiGhoXhdkvKl+JBHUbOEh/LMkLwqwISYSrxA8SSIAIwJ4 rhGO8qIwfPCq9sIwRgI63uLgCuuGSVokA58xXw8I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Bjorn Andersson , Sasha Levin Subject: [PATCH 4.19 031/138] soc: qcom: geni-se: fix array underflow in geni_se_clk_tbl_get() Date: Tue, 3 Dec 2024 15:31:00 +0100 Message-ID: <20241203141924.747441123@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203141923.524658091@linuxfoundation.org> References: <20241203141923.524658091@linuxfoundation.org> User-Agent: quilt/0.67 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 78261cb08f06c93d362cab5c5034bf5899bc7552 ] This loop is supposed to break if the frequency returned from clk_round_rate() is the same as on the previous iteration. However, that check doesn't make sense on the first iteration through the loop. It leads to reading before the start of these->clk_perf_tbl[] array. Fixes: eddac5af0654 ("soc: qcom: Add GENI based QUP Wrapper driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/8cd12678-f44a-4b16-a579-c8f11175ee8c@stanley.mountain Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/soc/qcom/qcom-geni-se.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c index 7369b061929bb..4e1c6c5ea9c92 100644 --- a/drivers/soc/qcom/qcom-geni-se.c +++ b/drivers/soc/qcom/qcom-geni-se.c @@ -542,7 +542,8 @@ int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl) for (i = 0; i < MAX_CLK_PERF_LEVEL; i++) { freq = clk_round_rate(se->clk, freq + 1); - if (freq <= 0 || freq == se->clk_perf_tbl[i - 1]) + if (freq <= 0 || + (i > 0 && freq == se->clk_perf_tbl[i - 1])) break; se->clk_perf_tbl[i] = freq; } -- 2.43.0