Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2137695pxp; Fri, 18 Mar 2022 04:17:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyfGBUZHRGU9PKChs0xq5ivBz+8KRprp51LvR4X9fsGQFbRFXRQDsU8r2k4zvATmcLFR7g X-Received: by 2002:a17:90a:560a:b0:1bc:72e7:3c13 with SMTP id r10-20020a17090a560a00b001bc72e73c13mr20751008pjf.246.1647602230287; Fri, 18 Mar 2022 04:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647602230; cv=none; d=google.com; s=arc-20160816; b=vvkupUQr0H+Y9jyAm+pt5F/vCNZtFf7V941Pllipb2suhWMvJTvdn2Ov8fP8jMN02C 6hKpnm+aMn5qaN4+Oa4G2/DSJTLKXwoG95BsoTeFiAv/hLEd/gZlC+oULSLoH3dB4MA8 9cZ9Lbpi7l1P328Y/o/lFPCfmHTOlPVDrnZw5gZY6Fx9gl+DkP/bekeWjB17gDIsvqfJ y4TxzAPXa3AINQWdmKQCXngmuWeIPVFyKGiffj8BpfwRPgSfY0ivrOZx2V0atyC7vUNM r6/Rbkw+1bXLKKYPE8JblKNpVFkreSnulI7nb6SrR8/bBo18p5k6VNZ8JTHcRRbcPZTE IyCw== 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 :message-id:date:subject:cc:to:from; bh=oZ53lmXcYwCyPx+a4EVS+RHJDD6L9dfq3Xi6EKRu5cY=; b=ac6w7FVtqXXuf813eQYfXVtQ29fytlWhDzf+0UpimJTUvbfmjuyNGt088SNPo1VTRL cRxSQmeSDy5W5foBm69RV2vvBHL/I7Uano/5zhxGF+1SUhEBqCBmWdBLPXzYFDi+TLyf NRROik6f0tC93oea0P77Bcx+5sbis8BkEIbGAserxwQIRLf0r2pIFYosEV7P6ei9W5gX Gtba91MuKF0RaKzNXeFv3uF1UZvGrtxmHlMQtY3wX8Uc11hY4ag5jo8K55SBs0SBZlmF mAF9D0ZTQDIELyaLvHBiHMU7cbijR/ROPrdfgijbUBD58F9rxdwZYSDALGfE4SAPEsge aiPA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a63b30b000000b003816043ef1bsi4946676pgf.272.2022.03.18.04.16.57; Fri, 18 Mar 2022 04:17:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234281AbiCRJ3s (ORCPT + 99 others); Fri, 18 Mar 2022 05:29:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbiCRJ3r (ORCPT ); Fri, 18 Mar 2022 05:29:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F1F0C2E35B8 for ; Fri, 18 Mar 2022 02:28:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F29516F2; Fri, 18 Mar 2022 02:28:28 -0700 (PDT) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF26E3F7B4; Fri, 18 Mar 2022 02:28:27 -0700 (PDT) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, Cristian Marussi Subject: [PATCH] firmware: arm_scmi: Fix sorting of retrieved clock rates Date: Fri, 18 Mar 2022 09:28:13 +0000 Message-Id: <20220318092813.49283-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,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 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. Fixes: dccec73de91 ("firmware: arm_scmi: Keep the discrete clock rates sorted") Signed-off-by: Cristian Marussi --- 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 cf6fed6dec77..ef6431c6eb1c 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -210,7 +210,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.32.0