Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1717987iog; Thu, 16 Jun 2022 12:14:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpr7w8UJPM32X01nJNxFtLCopJuANWHj+zDmnyYr7R6QpGTxrYY4OrFxofDaaH+EFUN9RS X-Received: by 2002:aa7:9a49:0:b0:51b:aa7f:d078 with SMTP id x9-20020aa79a49000000b0051baa7fd078mr6240152pfj.71.1655406852028; Thu, 16 Jun 2022 12:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655406852; cv=none; d=google.com; s=arc-20160816; b=u4sXY8qATJz9avuGpSTShKmId9c/+38nOrEeqQytZSWHoHfT+ZoP9Q9AN1KMJcg4Vh mdbMrCt3AcmsdmQf3kDPOT4OhTmoRmKrN4JsJ8fL5UfdpyRA0PCU3MzutT/OC8S+p3GD ARnUUIj9nOG9h03h3dMw6ihoupj8/fuq/BZCDy1tll6E0K87LDBJItzMe3sgDGp49CPQ RIAoCsbQ/rqXq332aaaYQlu12nLR1h8um5QrMSHQfo0fb0oq1ISWlE2p+DS1YhBUqBID Hv674i81ZbMcrBRh6MykZ16UFR1LwNHj9EE0tWv8oC3Ep/kXQnOedN5/f3mwYOAkfwNI EcRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=I4ura+VlgF2j0yjAri7ChNgfpq9HO2ZopOtROs/fk8k=; b=qW9MY/VCXPjW/JH2ebtqyR0gwrEh78p866euoE/4IePJ8UjFHUl8ZB0gbl4UsLmmQr uUaz+KP2ARmLf6GSk/qRSsagPtWbarCQM4a1M5jQYJ0Apzd6SEdM9kKqs12A5m+0resx ylTB2v3m4GiVX1Pvvh/ov8LSBObm6e6dlGPJfgMeNqVcS5VmozvLaFOLd1Nh7eBw8Hp3 Ctmkckh6/e6goG5KqtFT3YanZQRZHOlP9IQKMJXyAXl1RJ2lU7iRZxQDDQFTjJaL6VZe RWJJAT8PkALYspMV9IeCEpDzAmpNuljGIX93VAnoveMtHXvFtrosLL6h8z3m4PHXthDN 8cOQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b123-20020a633481000000b003fe29d0c24fsi3611596pga.71.2022.06.16.12.14.00; Thu, 16 Jun 2022 12:14:12 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377820AbiFPTIj (ORCPT + 99 others); Thu, 16 Jun 2022 15:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378036AbiFPTId (ORCPT ); Thu, 16 Jun 2022 15:08:33 -0400 Received: from smtp.smtpout.orange.fr (smtp10.smtpout.orange.fr [80.12.242.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F3D36321 for ; Thu, 16 Jun 2022 12:08:32 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id 1uqzoyzz62ovC1uqzoKVy7; Thu, 16 Jun 2022 21:08:30 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 16 Jun 2022 21:08:30 +0200 X-ME-IP: 90.11.190.129 Message-ID: Date: Thu, 16 Jun 2022 21:08:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2] bus: (mvebu-mbus) Add missing of_node_put() Content-Language: en-US To: Liang He , pali@kernel.org, lpieralisi@kernel.org Cc: linux-kernel@vger.kernel.org References: <20220616020135.3973141-1-windhl@126.com> From: Christophe JAILLET In-Reply-To: <20220616020135.3973141-1-windhl@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Le 16/06/2022 à 04:01, Liang He a écrit : > In mvebu_mbus_dt_init(), of_find_matching_node_and_match() and > of_find_node_by_phandle() will both return node pointers with > refcount incremented. We should use of_node_put() in fail path > or when it is not used anymore. > > Signed-off-by: Liang He > --- > changelog: > > v2: (1) use real name (2) add of_node_put when not used anymore > > v1: add of_node_put in fail path > > > drivers/bus/mvebu-mbus.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c > index db612045616f..e168c8de2ae8 100644 > --- a/drivers/bus/mvebu-mbus.c > +++ b/drivers/bus/mvebu-mbus.c > @@ -1327,22 +1327,28 @@ int __init mvebu_mbus_dt_init(bool is_coherent) > > prop = of_get_property(np, "controller", NULL); > if (!prop) { > + of_node_put(np); > pr_err("required 'controller' property missing\n"); > return -EINVAL; > } > > controller = of_find_node_by_phandle(be32_to_cpup(prop)); > if (!controller) { > + of_node_put(np); > pr_err("could not find an 'mbus-controller' node\n"); > return -ENODEV; > } > > if (of_address_to_resource(controller, 0, &mbuswins_res)) { > + of_node_put(np); > + of_node_put(controller); > pr_err("cannot get MBUS register address\n"); > return -EINVAL; > } > > if (of_address_to_resource(controller, 1, &sdramwins_res)) { > + of_node_put(np); > + of_node_put(controller); > pr_err("cannot get SDRAM register address\n"); > return -EINVAL; > } > @@ -1360,6 +1366,8 @@ int __init mvebu_mbus_dt_init(bool is_coherent) > pr_warn(FW_WARN "deprecated mbus-mvebu Device Tree, suspend/resume will not work\n"); > } > > + of_node_put(controller); > + > mbus_state.hw_io_coherency = is_coherent; > > /* Get optional pcie-{mem,io}-aperture properties */ > @@ -1378,6 +1386,11 @@ int __init mvebu_mbus_dt_init(bool is_coherent) > return ret; I guess that a "of_node_put(np);" is missing before this return. This really looks like an error handling path and it has not been updated as all the other path, including the normal one below. Moreover having an error handling path and some gotos is a more usual solution. It avoids code duplication. (but it is also a matter of taste...) CJ > > /* Setup statically declared windows in the DT */ > - return mbus_dt_setup(&mbus_state, np); > + ret = mbus_dt_setup(&mbus_state, np); > + > + of_node_put(np); > + > + return ret; > + Nitpick : This extra new line is not needed. > } > #endif