]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
firmware: arm_scmi: Fix sorting of retrieved clock rates
authorCristian Marussi <cristian.marussi@arm.com>
Fri, 18 Mar 2022 09:28:13 +0000 (09:28 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:42:14 +0000 (14:42 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969857
[ Upstream commit 23274739a5b6166f74d8d9cb5243d7bf6b46aab9 ]

During SCMI Clock protocol initialization, after having retrieved from the
SCMI platform all the available discrete rates for a specific clock, the
clock rates array is sorted, unfortunately using a pointer to its end as
a base instead of its start, so that sorting does not work.

Fix invocation of sort() passing as base a pointer to the start of the
retrieved clock rates array.

Link: https://lore.kernel.org/r/20220318092813.49283-1-cristian.marussi@arm.com
Fixes: dccec73de91d ("firmware: arm_scmi: Keep the discrete clock rates sorted")
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/firmware/arm_scmi/clock.c

index 35b56c8ba0c0ef7047ecb0e87678df889385758e..492f3a9197ec2d4bfe70eced524b40a64efc479a 100644 (file)
@@ -204,7 +204,8 @@ scmi_clock_describe_rates_get(const struct scmi_protocol_handle *ph, u32 clk_id,
 
        if (rate_discrete && rate) {
                clk->list.num_rates = tot_rate_cnt;
-               sort(rate, tot_rate_cnt, sizeof(*rate), rate_cmp_func, NULL);
+               sort(clk->list.rates, tot_rate_cnt, sizeof(*rate),
+                    rate_cmp_func, NULL);
        }
 
        clk->rate_discrete = rate_discrete;