From: Gabor Juhos <j4g8y7@gmail.com>
To: Taniya Das <taniya.das@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Dmitry Baryshkov <lumag@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: qcom: rcg2: validate frequency table entry in __clk_rcg2_shared_set_rate()
Date: Thu, 29 Oct 2026 09:16:05 +0100 [thread overview]
Message-ID: <974845a6-16bf-41ad-932b-244112b85cae@gmail.com> (raw)
In-Reply-To: <d0492d0f-42a5-4400-80d0-987086d7d224@oss.qualcomm.com>
2026. 10. 27. 19:24 keltezéssel, Taniya Das írta:
>
>
> On 10/27/2026 11:35 PM, Gabor Juhos wrote:
>> Commit aec8c0e28ce4 ("clk: qcom: rcg2: add clk_rcg2_shared_floor_ops")
>> removed validating of the frequency table entry pointer returned by the
>> qcom_find_freq() or the qcom_find_freq_floor() functions.
>>
>> Since both functions can return NULL and the pointer is passed directly
>> to the __clk_rcg2_configure() function where it gets dereferenced
>> unconditionally, it could cause a panic.
>>
>> Restore the sanity check removed by the mentioned commit in order to avoid
>> a possible NULL pointer dereference.
>>
>> Compile tested only.
>>
>> Fixes: aec8c0e28ce4 ("clk: qcom: rcg2: add clk_rcg2_shared_floor_ops")
>> Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
>> ---
>> drivers/clk/qcom/clk-rcg2.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
>> index d7914e59129f..260e90f53461 100644
>> --- a/drivers/clk/qcom/clk-rcg2.c
>> +++ b/drivers/clk/qcom/clk-rcg2.c
>> @@ -1385,6 +1385,9 @@ static int __clk_rcg2_shared_set_rate(struct clk_hw *hw, unsigned long rate,
>> return -EINVAL;
>> }
>>
>> + if (!f)
>> + return -EINVAL;
>> +
>
> Normally, the CCF calls .determine_rate before .set_rate. The floor
> determination helper already rejects a request below the lowest supported
> frequency:
>
> ```c
> if (!f)
> return -EINVAL;
> ```
>
> So an ordinary clk_set_rate() request below the table minimum should
> fail during rate determination and typically not reach
> __clk_rcg2_shared_set_rate().
>
>
Thank you for the explanation, it makes sense.
In this case, we don't need the patch.
Regards,
Gabor
prev parent reply other threads:[~2026-10-29 8:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 18:05 Gabor Juhos
2026-10-27 18:24 ` Taniya Das
2026-10-29 8:16 ` Gabor Juhos [this message]
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=974845a6-16bf-41ad-932b-244112b85cae@gmail.com \
--to=j4g8y7@gmail.com \
--cc=andersson@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=sboyd@kernel.org \
--cc=taniya.das@oss.qualcomm.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
all inboxes | Powered by JetHome®