Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3345289rwb; Tue, 8 Nov 2022 03:34:28 -0800 (PST) X-Google-Smtp-Source: AMsMyM7+mkSVmNgtJwm/MczJ2l5UIHTqP6EQuFbRjJqGPSDC44ImOPF0U+kU4nZr2rFXJC42sMk+ X-Received: by 2002:aa7:d996:0:b0:461:88b8:c581 with SMTP id u22-20020aa7d996000000b0046188b8c581mr55493885eds.111.1667907268668; Tue, 08 Nov 2022 03:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667907268; cv=none; d=google.com; s=arc-20160816; b=NWSyQ796La1r0o3JzfcTLIqHQkmZFcfOTLBS0prUhxP3E5ZevGEXjMQBrgSW/iP1+c C2RKSWgnmaHny15EtfZE9nPFQTxhlzMmc3oh8S3RxlMEt5VPMTb2/yfUOwFNHu9MmFEv fdTMRtA8imiiIxwMQWAf4Wv56Qycc/OR5JF+CCxy01rcvssgIyZ4Gg+GEbSrB1ni3YQv tDN3kVKxCMLdgZ1DYr0pf6sGJ134BfT5Irk/gJtRLEudx0+hIvBiv3bohrPr5+t2XZHU 7xWbRgSuDcbwD23EjYlCgIn2C77mOyMX1uORnsFewflaenCvG23N9+Nqs0aXpccy11IW n3Jg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a05640242c700b00463a4ca44e0si15990042edc.138.2022.11.08.03.34.07; Tue, 08 Nov 2022 03:34:28 -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 + 89 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=20Wilczy=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 Content-Transfer-Encoding: 8bit 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 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 --- 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 -- 2.25.1