Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp861039pxb; Thu, 21 Apr 2022 12:01:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ycnrTk5GQ4gQkM/BlwEBAeWPd0GxBdDeCh3L+3JAT8eB1Q46i09m3WHpSr7T7LIz5Ikn X-Received: by 2002:a17:907:da6:b0:6ec:f599:b053 with SMTP id go38-20020a1709070da600b006ecf599b053mr812339ejc.503.1650567675381; Thu, 21 Apr 2022 12:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650567675; cv=none; d=google.com; s=arc-20160816; b=FFEsEc8XBm4ARnlnp9vZwuXNmCiw8ISeFGqldAVlamg5AnTUhfzdcARxg7NPz6892m rt5VyEvWtFSGeqGI7c771ZxyQhwLqjk/KttSfNxizGU3z8kThz3R0zEqoWS67SpwfpfP Qdd33NCKQwFjVznymhAUVFir1tkck8ycYKy7ykquhPO1x8zACxQqZsqseAO1o5ZxaCyi +xnn9fWMmw3Y9EF/+QggJQY9kJZTGy0uHmeTbaiYY0hKcYi/sn6gNZiwFsMbrUo1Iqwv 8kgxAO42qahwQ1PHjwy4ON3z9+2hcNOS0DeO6jegqep/m1MqxElc+8EwAixGu++D+EHR bNnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RsCXtG23dotr24pOGS453hSXO+w488rKQLJLuHT9I7c=; b=pqdbDfM6R9kcbm3OIU25p6K5XLYU0gf2s0sngdJHZjAdGhUmyVXC2ARF86qbIJdiqp 5a24xIJuQRd87RG/1yFN8kDV1s/CpfXvTBX+CAkwIUkDzlIinDEsyQfz8GcSYADD/E1z cyqvcJZ6MtwaZdw6XQ7kxCH0oo14fOkXffQus8Dh5hinygBhlaysAEH6jH4BFH485Hzg E17VG95JxBDfJVx2S58wpn80yEkPg3RCKs1M/lDjpbNcX4wvvjdAuRIcLTX/aGPLj+pg tEO1qnBtxoz3hrKcjlR/iufhgjUM1F1TRDxITeFOfMLcxLHdyo8NPYISNqOqH9d/Tu2s QZ8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPDtiW4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vs24-20020a170907139800b006e8c7f3992dsi3576315ejb.649.2022.04.21.12.00.46; Thu, 21 Apr 2022 12:01:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPDtiW4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238479AbiDRMXh (ORCPT + 99 others); Mon, 18 Apr 2022 08:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238707AbiDRMWp (ORCPT ); Mon, 18 Apr 2022 08:22:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FBD1EC6C; Mon, 18 Apr 2022 05:18:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C7A1FB80ED6; Mon, 18 Apr 2022 12:18:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3678DC385A7; Mon, 18 Apr 2022 12:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284284; bh=i9onWB9tRvxnJHS7hD+ihyIKDO/WpE3i++NR8WHGdnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPDtiW4xJRLBaLWZQ1JUCBQsrUpxjMC35wIcFBiOlq1nypyfNesOvqLZKiyl1/b2e KqHd1OkbRazFi+Fm5bVOcmZ+I9mP9/7g6lbG62s6y65LSOmVznbkhYTKTsTkZ9+2oX sdVjY/WU07FkeED4LyrQY7NjDGeFcfxLEV/fkI9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cristian Marussi , Sudeep Holla , Sasha Levin Subject: [PATCH 5.17 063/219] firmware: arm_scmi: Fix sorting of retrieved clock rates Date: Mon, 18 Apr 2022 14:10:32 +0200 Message-Id: <20220418121207.320306740@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cristian Marussi [ 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 Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 35b56c8ba0c0..492f3a9197ec 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -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; -- 2.35.1