From patchwork Mon Nov 21 17:12:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 23958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1719048wrr; Mon, 21 Nov 2022 09:16:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7JPqRS+142sasRcqnYjdHrhXCtb99abpPSA7KMD5htAF+LqLUuM+upd44jtNKIOVOIpCw7 X-Received: by 2002:a17:906:7f07:b0:7ad:b216:f1ce with SMTP id d7-20020a1709067f0700b007adb216f1cemr16134984ejr.419.1669050963520; Mon, 21 Nov 2022 09:16:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669050963; cv=none; d=google.com; s=arc-20160816; b=vVAcHstiTbFz8zsBEvWufUwjTOtnNeVZ4Z6FV7m6yERGS6XrhuAV4z+POcb0FL1vhc v2onMXXKAGEqKLRWm6xF9YBgiygZrVk5/+Og/YKF3TOcz52rrM/at4fkA8rbQKNZW5nj zer4G1u8EoGOFCeugmS9FHu3DgzMWwfFICOckeWlDGKZFG0WnxgatkFFQhLNE3iIAtEq dgDbDeIOvC+N3lNEHNwOJAyWxYAfxkH7uyIbW7o5zIpChtINtI04fDMIhDt35Oyh0dkD 0weMdbjo9w5Rd51esb6VRt9WDGv9M8Yztd9Wif2IOhYVRiLp5PfeVDE7WLfAiYOFQ60C aQ7A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sRivNmaLyE4Rv8iZrprXeZRZhzns7soaBNqOnl563u4=; b=XINFzlUR7/aHv0EgeB0i3T1PwaefeUvnLWEke7624d3nd7MKDVZmidILVxEuomXDeQ SiHS8OY5WKfsps5/pDw6ipop5ldB1tZ5TogAi7MWw8zISqCEJqkYAiuEqNo2VD2deQPv BEiMKHK/HHUyzdpnAMayIEDsxxlVoctIARhXtgpxE98TFhIdeW3QgV1ubnCedbeiTpBH VPHJaC3VUwJDg002ehspiFRhFQ/qmPGwyyOzvi+6QhLl6xQDZgwfb+IBDdv/vsU/5s9r sYdj1pPNtiIFIZEd2zivcQsPIArWIBXXX92xxugA1lrxvH4pFlOt0xfR564IuXlZqLB5 CynA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020aa7d946000000b0045a0e39062esi9030134eds.76.2022.11.21.09.15.39; Mon, 21 Nov 2022 09:16:03 -0800 (PST) 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 S231487AbiKURO6 (ORCPT + 99 others); Mon, 21 Nov 2022 12:14:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231256AbiKUROb (ORCPT ); Mon, 21 Nov 2022 12:14:31 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7666FD32AB; Mon, 21 Nov 2022 09:13:03 -0800 (PST) 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 6E29712FC; Mon, 21 Nov 2022 09:13:08 -0800 (PST) Received: from pierre123.arm.com (unknown [10.57.7.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EAB603F587; Mon, 21 Nov 2022 09:12:56 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Rob.Herring@arm.com, Pierre Gondois , Sudeep Holla , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Jeremy Linton , Conor Dooley , Gavin Shan , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Alexei Starovoitov , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org Subject: [PATCH v2 2/5] cacheinfo: Return error code in init_of_cache_level() Date: Mon, 21 Nov 2022 18:12:10 +0100 Message-Id: <20221121171217.3581004-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121171217.3581004-1-pierre.gondois@arm.com> References: <20221121171217.3581004-1-pierre.gondois@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750126783417161827?= X-GMAIL-MSGID: =?utf-8?q?1750126783417161827?= Make init_of_cache_level() return an error code when the cache information parsing fails to help detecting missing information. init_of_cache_level() is only called for riscv. Returning an error code instead of 0 will prevent detect_cache_attributes() to allocate memory if an incomplete DT is parsed. Signed-off-by: Pierre Gondois Reviewed-by: Sudeep Holla --- drivers/base/cacheinfo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index a4308b48dd3e..6f6cd120c4f1 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -246,11 +246,11 @@ int init_of_cache_level(unsigned int cpu) of_node_put(prev); prev = np; if (!of_device_is_compatible(np, "cache")) - break; + goto err_out; if (of_property_read_u32(np, "cache-level", &level)) - break; + goto err_out; if (level <= levels) - break; + goto err_out; if (of_property_read_bool(np, "cache-size")) ++leaves; if (of_property_read_bool(np, "i-cache-size")) @@ -265,6 +265,10 @@ int init_of_cache_level(unsigned int cpu) this_cpu_ci->num_leaves = leaves; return 0; + +err_out: + of_node_put(np); + return -EINVAL; } #else