From patchwork Tue Nov 8 11:04:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 16986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2633075wru; Tue, 8 Nov 2022 03:07:19 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Id9WUyC3SJWy/zaF8TvJkHudm6zfZx5x0dvYJtMnAoLgx/LBCWbQpNeUx0IBEMQmMnfrt X-Received: by 2002:a05:6402:2b8d:b0:43a:5410:a9fc with SMTP id fj13-20020a0564022b8d00b0043a5410a9fcmr55924752edb.99.1667905639333; Tue, 08 Nov 2022 03:07:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667905639; cv=none; d=google.com; s=arc-20160816; b=Webl6w42cQtofj2/+0mTFCECVcDb+PLxBgziMWFD15k5vOl6bkkzl6qO6vfwhFS1J2 X5Da+CuasGxzDMLfaA1notdXM/Vmhm9yrLPCK+R0kehDEkg5R8iHGbg1TXdrTpTm/dWo EGqyFzpsVtpA9TgB1UgQKUbYI8A1NZymmiP9huGp5LzxHKo1mm0SnE/66dWJfRwn+llS DpMryLBqFpP7X4xQ4JoHCdv4ZYsNdKw43Z9mxIwFVjpsUTgm+rLMdx20svwd4Xe3N+XZ NgJqSKWSuOfbI864I7ibg1zduNroe4q9LBCMhoaBuKmXfy0LxLfSUL0Fisbz+PIwDWq2 91gA== 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=oIvH2b6vJRFYn+AZXEiKelS8T6KAg6r23YMPz1I2bKk=; b=hr6QxyYKKzkFDh1EZd0h8m7lNBeRAfpJYHBJi6uRat7Bi8r5IuXme5o2XVGsEu/ZSE pFtlIlkb9DMaHfpVM4Sjg0J7no9MKaAugWXD9LRts8YJhCTR7QTN3IQTmFnxDkjSsFIp eRoTUQI720YefDdYZ7Tao5lKW2drwnsbbEZEhXrBiMXU6j1dLLxjmwocItggqww4TABe 5Dw/X9uZutftELUsI0HX/NtPSSK5gCuA1FRuIUFvltVvMdr39i7o9QnKAHQqJg+90Qgz x/fTHLMYRkCGyjSxOeNjgM8FZF7mdYheDLwi5+ONE3fYrWSRPdXdOAEt1rAN4yto6ntH Q4VA== 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 m14-20020a50ef0e000000b00457e6752422si10817022eds.189.2022.11.08.03.06.55; Tue, 08 Nov 2022 03:07:19 -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 S234024AbiKHLGW (ORCPT + 99 others); Tue, 8 Nov 2022 06:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbiKHLGM (ORCPT ); Tue, 8 Nov 2022 06:06:12 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF5F349B44; Tue, 8 Nov 2022 03:06:11 -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 97743ED1; Tue, 8 Nov 2022 03:06:17 -0800 (PST) Received: from pierre123.arm.com (unknown [10.57.5.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 918CD3F534; Tue, 8 Nov 2022 03:06:08 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Pierre Gondois , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Len Brown , Sudeep Holla , Greg Kroah-Hartman , Gavin Shan , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , SeongJae Park , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org Subject: [PATCH 2/5] cacheinfo: Return error code in init_of_cache_level() Date: Tue, 8 Nov 2022 12:04:18 +0100 Message-Id: <20221108110424.166896-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221108110424.166896-1-pierre.gondois@arm.com> References: <20221108110424.166896-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?1748925823504767940?= X-GMAIL-MSGID: =?utf-8?q?1748925823504767940?= 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