From patchwork Tue Apr 26 07:49:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 566008 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3367518map; Tue, 26 Apr 2022 00:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPkloyySShwRrDl0rmbN5x5vjX7f339GVt1GkLFP2VO9FScBFOW8Htn2E2Qr7DAX6mz0F2 X-Received: by 2002:a05:6402:1e8c:b0:424:1d6:1b71 with SMTP id f12-20020a0564021e8c00b0042401d61b71mr23213251edf.211.1650959408183; Tue, 26 Apr 2022 00:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650959408; cv=none; d=google.com; s=arc-20160816; b=HnDG1gRxdVXR/Fvq3E3fic0XIG3OKBGGte4ZpJwCUEH+WCtw/alv59CHcCB2Yn7tq/ /9wUUCE2RPUgPGaH/iLFi1I0y4+lrBO17W9V82A/hzhizmuDfh+l2xY5ndWamMsvT20P vw0xSmeXELIZATl+XrkXI+o15JKBrfiKCoUkd4UM2xMfe29crIUv0w9zS87aiJy5FpKT Ud4L4pC0BUi3HiPm3ccqMn5UNoEnyzt/wSdsCwWyDV0t9uquUqLEC1YSybZ3YDcd/q7s ZDRdi1IwCEsgdpjsBFdaWhVyR8UzGiN7U+745JYhVhrpPASK+iNkQbMV+xB/a8LWkFxG 8nrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=b1mPoR+RLEaWmQdi7ARVC7TEjH2wokPt3xms5hIN15I=; b=cIrkr7CE5lAiTTZEh2wmUSmBEk82tx0u/pKGOnroo5fNEesKEtcDLQPur1B3IIxEvz gKZizb88sdcLtlGaJVp+B83RibU++gkIQnE+u8ofw6HjIixSLAWj+0SkxKLxIDH8gpfM pQBsmVAWh1DXra0JHB3uFqmWphX6hSoT5TvE8CSZM6SyRuCNzhbIpMksm2g50mWp1RS8 HpxTq2RT1096l85tKEJ4Urv8YTXOncnvQVy6caJxNTWuYCC3TUAUShIdUU66L1QVi8RU m6rnXdooz7kLavJVKiOUhXwR10F0pzu90Vda4T43C1w/cN564d+0o5LMQ9vgBzpVNLF7 ASQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N6ELbFwx; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id hh23-20020a170906a95700b006e8bd883224si15469270ejb.792.2022.04.26.00.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 00:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N6ELbFwx; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19E2E8053F; Tue, 26 Apr 2022 09:50:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="N6ELbFwx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D32BB8399B; Tue, 26 Apr 2022 09:49:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 145D68021F for ; Tue, 26 Apr 2022 09:49:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id bg25so9931132wmb.4 for ; Tue, 26 Apr 2022 00:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=b1mPoR+RLEaWmQdi7ARVC7TEjH2wokPt3xms5hIN15I=; b=N6ELbFwxXE75PnIXzXD1VkVAb8VOmQes0+zPeHHs6ZlSeu/Gr55Tw8kqGIIevj/9qE RIZhkNREBYdxPqDAzwZOF3RuEIbc1JF4MT9WTzuACtaH0PYevfCX93ukXujH2+jW38TG BgdMAvo6X1XWdYTASgpevwYHXBJGcM8hGHu5BizBCT7bFpn7PXWbRbCMG/ew5CdPhPEK 3SaHOAIimny/b0uZqMlDkKkoBQ0k8zTXUo+8NxJCrALFIBBH9wzjl87K9RlIVOq0Tj0I wpo/UP3YZzmTQdDtMUZJzpt3Aqrb9Q0JvI4zxmyWmUFDFiS8nXLHnqY7Wzr8BJASA4HK yC1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=b1mPoR+RLEaWmQdi7ARVC7TEjH2wokPt3xms5hIN15I=; b=gQx0paPk8jiKjDi7Ss9AWd89QNdL9C2s1Uspyhinr0ihQd7UrTl1tVJdwtr4TNFPt/ 1qHIJnr9XMbT7ttyDjzWKUBE1ulA3EEmlfwwITSqr0C1z51lSFs5JkB/8tDbEp2mXb6r hsqQleTQoPSrlp03amqN5+ErJJc6NzZRhnalrEY3qqQ606zNROl3K4FNX/UKNRJyQ2fw bul6YuKHAgAxUMBq20oWccttmpVmnXAgXoGCAV7a+o+drpjIf4XxGX/in2hYOO2J4uSg M1IvBQV+8JCFd8OX8hU4HyxFUQTAgpz3CGgj4UkejzQ8qLgE59pp3onBOhmL7Zeg2Sn9 lD7g== X-Gm-Message-State: AOAM531yUiXf/ChRvKO4RoN5OpY8dghPxv5pJb3x5MXlW+Q2gExaJfHq B/wCDfIoSAgSSPtP0glujqYs7Uh/TMC4Og== X-Received: by 2002:a05:600c:4f0d:b0:393:ec48:ecb1 with SMTP id l13-20020a05600c4f0d00b00393ec48ecb1mr7666765wmq.11.1650959389405; Tue, 26 Apr 2022 00:49:49 -0700 (PDT) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10a4:d1:b81d:eca1:1a27:59be]) by smtp.gmail.com with ESMTPSA id b14-20020a7bc24e000000b003899c8053e1sm11840060wmj.41.2022.04.26.00.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 00:49:48 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Lukasz Majewski , Sean Anderson , Patrick Delaunay , Gabriel Fernandez , Etienne Carriere Subject: [PATCH] clk: scmi: fix invalid clock name references Date: Tue, 26 Apr 2022 09:49:45 +0200 Message-Id: <20220426074945.2229-1-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Fixes clock name references in scmi_clk driver. SCMI clock names are retrieved from the SCMI firmware by invoking SCMI commands using the stack for SCMI response message hence clocks names located in the stack must be duplicated before being registered in the clock framework. Fixes: 7c33f78983c3 ("clk: scmi: register scmi clocks with CCF") Reported-by: scan-admin@coverity.com Signed-off-by: Etienne Carriere --- drivers/clk/clk_scmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index 57022685e2..5019aacef9 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2019-2020 Linaro Limited + * Copyright (C) 2019-2022 Linaro Limited */ #define LOG_CATEGORY UCLASS_CLK @@ -12,6 +12,7 @@ #include #include #include +#include static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) { @@ -53,7 +54,9 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) if (ret) return ret; - *name = out.clock_name; + *name = strdup(out.clock_name); + if (*name) + return -ENOMEM; return 0; }