From patchwork Tue Apr 26 07:52:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 566009 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3368975map; Tue, 26 Apr 2022 00:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3WMMM1zTwXvotkTAQTik3+T7XfKW4XZe0nZB6zG03Rn2AT8pBePB5E2C/LKwmM9Rswq0X X-Received: by 2002:a17:906:a08b:b0:6b9:2e20:f139 with SMTP id q11-20020a170906a08b00b006b92e20f139mr21053733ejy.463.1650959567867; Tue, 26 Apr 2022 00:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650959567; cv=none; d=google.com; s=arc-20160816; b=icxt3IEYKr1b4PsGtvR5tqEcMCi7d8fB9+IU4/6lKatCNt2a4JFynvC8kL/1mI5VQm J9tnmgeOhE9su9lQbM0S7FAZ3BVpyfrBnvMSSG76IIRuzSKUG39k2GRMAMd5FUv0d7OP kxRulxUqxpoL6QT4sjbTNsm2ML4wp1xbWUGoQgHETepqEaCgvxrDnoMoKfwxUYSWLdIL aCuwf+ajD4jVBhwQyORvRe6cZp+Dp/Mzk1xLluln/Hf6owQqj4wZCajCgDAQO+zYpMJ6 O2wboAtx7ABVcYQrk4cNsyK2Y8WkO9cWNoyyRNePJZyS6KCRmoiKRZ1NRJQZc62aqnt7 aJWA== 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=zAhM7wbjUMQWPvazn85/M0MNf+Jn5FKHDaRdzsxxz5I=; b=NVVx4t1rarJgG54KZH00aWsNjbtCDB3yrAg3MTrifXLai0Dy79MIF+NQTcXf1Q0lsf rHB8ZDY02K6giCUs4DrJozwwsji/sjkM4zrbI+c3pjlfRktcsHGDkEGAm4p9mn1daySG ct2Btu5Tl+SYIm9e5UxTZ+Opl0qfbqzCkUGN/2dCaD5bRRWI0a1gACxMYzOAu5O3fKZs SAEG+gU9uBBg4/wtOPrYGcg5P+KLNXVfaX6Z2Au/e6DAuNfPv5lLM7Udjpt1JRCTfDtf 0E4k4jO3NAFjVZ/B7D9l+D4BwRGZK0ZapraKiobaWXDzuo0u1g3zFJtkBHY3Ii4STqZY E1uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXghCxjc; 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 f16-20020a0564021e9000b00425b86904dcsi11657863edf.146.2022.04.26.00.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 00:52:47 -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=JXghCxjc; 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 557828399B; Tue, 26 Apr 2022 09:52:43 +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="JXghCxjc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E67E38053F; Tue, 26 Apr 2022 09:52:40 +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-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 4A1EC8186D for ; Tue, 26 Apr 2022 09:52:37 +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-x330.google.com with SMTP id a14-20020a7bc1ce000000b00393fb52a386so328008wmj.1 for ; Tue, 26 Apr 2022 00:52:37 -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=zAhM7wbjUMQWPvazn85/M0MNf+Jn5FKHDaRdzsxxz5I=; b=JXghCxjc7zJVjxbCj9Zr+Wejb37r8k9kOxy5s2FJO69nhrttMptZ32xjATt4SW42f8 4pSOjoYevtW8CiGYwjLA1YtCbzAk8PkGwsVwREhEAfOpwrGttK4vLqZVbB6Jt+x/ZWAb kVg2/6yU9qqYg+pvlkEjC3YldwTXmWKgDzgcx0E6wat3YXeCmZ2GHSjdsbZ6VSDbwjCK /aMUSpWujpkuJAsk06+j2J3Is5NUuSqHeJhAdtOHhRkXQqYsOE1mUp0SVS5qibsGPbGd Nz5d4moo826UEJee2qQCgqG/VPPVuKVrTeXGPDehpvgOKOWu/CuvIsb5QwWtu/mbALkz vldg== 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=zAhM7wbjUMQWPvazn85/M0MNf+Jn5FKHDaRdzsxxz5I=; b=P8YRUkJznr0yZDiGC9q9qHlgUZbhzkEDpRxBvyl0r3/gkzGGayWyR+E3LAy3NTGEmU 94w4ukafL++Na7akR4Pp1nWlUrqi6UjPZNtUYV4HjvcO9gvPkS6rOdTkxzzRieoLF+Uf 8/hyiDNfrcX6+lUkmm2lUX2yJofax0HJrc2CLGz0775BGflXor5bdB1mzQrfahIMNVfH Ye7IrFTmbs3z1SLPBprw9mcX9uVU0JqcqYB413snrl0PjNs4e2W1GXwdM6bfW8kmDciw IbylWqqdf+dcvPrZ3s0FyjnJ+YJ4sITZpdvuKhic5AZZ0J3YmMYa1qENdoDTPsWC3l3Q v9IA== X-Gm-Message-State: AOAM530Q/hN/3apGTc9nepno6Aann4quHIlBsfNOgCldE1o+HfUHpQgN +Zlu3YSQWa+JYmdvp1C3uLNXa39V9eSqBA== X-Received: by 2002:a05:600c:4e50:b0:392:8fe7:4700 with SMTP id e16-20020a05600c4e5000b003928fe74700mr29349360wmq.89.1650959556570; Tue, 26 Apr 2022 00:52:36 -0700 (PDT) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10a4:d1:b81d:eca1:1a27:59be]) by smtp.gmail.com with ESMTPSA id f14-20020a5d568e000000b00207ae498882sm10402654wrv.32.2022.04.26.00.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 00:52:36 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Lukasz Majewski , Sean Anderson , Patrick Delaunay , Gabriel Fernandez , Etienne Carriere Subject: [PATCH v2] clk: scmi: fix invalid clock name references Date: Tue, 26 Apr 2022 09:52:28 +0200 Message-Id: <20220426075228.3239-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 --- Changes since v1: - Fix buggy test on strdup() return value --- 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..c8e10c4aea 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; }