From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC1F0C433F5 for ; Sat, 12 Mar 2022 02:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiCLCCX (ORCPT ); Fri, 11 Mar 2022 21:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiCLCCU (ORCPT ); Fri, 11 Mar 2022 21:02:20 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AEA129E00F for ; Fri, 11 Mar 2022 18:01:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id A6318CE2B35 for ; Sat, 12 Mar 2022 02:01:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D59C340E9; Sat, 12 Mar 2022 02:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647050472; bh=jlJTQC9rL0Ohy92tmOfNWwQooasADfiPhpQpT96wHT8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=fbl40iQmu8txLiFBKEbYE87/V1sERSDFH6uAO0+5GS7MChg26w54kZeRfO4Nzrwqj ZbrLkjWJLk2TktdvkZwqaiRpn/Cu0ANALocft3bD+gI2aoYHndgi9m2ylD1KOqYteX siqCfjrZ8kVfjYh7PsfBqBRfGTl0CQHcSE2UqD6dAbbgX47pPeLrvXuG5x5Dp0Ln4n 7H7YaPpX/4HKIPs1oOTUJYsCw5Syl/j4HbtAQIdiLQ6Iccwov3+zTQZsBeaiU96pJQ iuH1YRvi3w7fzTFy/pacesE9nssq3TfFIbjhGBiHswZSZBPE4iENNXUQSnIN6t7PEx bXd/T5MfXfOlw== Date: Fri, 11 Mar 2022 18:01:11 -0800 (PST) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Miaoqian Lin cc: Stefano Stabellini , Russell King , Catalin Marinas , Shannon Zhao , Julien Grall , xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm/xen: Fix refcount leak in xen_dt_guest_init In-Reply-To: <20220309102442.14726-1-linmq006@gmail.com> Message-ID: References: <20220309102442.14726-1-linmq006@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Mar 2022, Miaoqian Lin wrote: > The of_find_compatible_node() function returns a node pointer with > refcount incremented, We should use of_node_put() on it when done > Add the missing of_node_put() to release the refcount. > > Fixes: 9b08aaa3199a ("ARM: XEN: Move xen_early_init() before efi_init()") > Signed-off-by: Miaoqian Lin Thanks for the patch! > --- > arch/arm/xen/enlighten.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c > index ec5b082f3de6..262f45f686b6 100644 > --- a/arch/arm/xen/enlighten.c > +++ b/arch/arm/xen/enlighten.c > @@ -424,6 +424,7 @@ static void __init xen_dt_guest_init(void) > > if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) { > pr_err("Xen grant table region is not found\n"); > + of_node_put(xen_node); > return; > } This is adding a call to of_node_put on the error path. Shouldn't it be called also in the non-error path? Also, there is another instance of of_address_to_resource being called in this file (in arch_xen_unpopulated_init), does it make sense to call of_node_put there too? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15727C433EF for ; Sat, 12 Mar 2022 02:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:Message-ID: In-Reply-To:Subject:cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iGgli7YHNoNGOhXaFvj0ICSTlxXAuzQKyYTQ4SB9XYE=; b=C9xwQjI1X/TEts vAsIZZk+PsyXvs8X66DP+So8jVG9Po1ApFPXxvQt77bZzMYYk/T7yZlwwARCnjD5EZnFvWOTIiJHT rdEglmeIeuEMdWDCjAhCvzsZ/95Vrc/Xpif4vNNhbQ2qcueGfOhDD4XI1vB1T1VJhd/cmHn7mI50e Jlu4rdMzPQemtwm3a1Ro5CQ/emVedktC99XipNZhU1ClHXsbB6+qSbWVhOys7p1p1xYkwQDr8655m rssJYKOnFPQ2YsnpVm6uM7DU7k4htgZjSpm6rcEYV/wk0VqVgUfT+NojHrt2cpbI4yR+8IjdE+zJw +88tvSr8klVGWubu2ueg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSr4K-000Z0U-4l; Sat, 12 Mar 2022 02:01:20 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSr4G-000Z0A-7d for linux-arm-kernel@lists.infradead.org; Sat, 12 Mar 2022 02:01:17 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 136E6B80EF1; Sat, 12 Mar 2022 02:01:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D59C340E9; Sat, 12 Mar 2022 02:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647050472; bh=jlJTQC9rL0Ohy92tmOfNWwQooasADfiPhpQpT96wHT8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=fbl40iQmu8txLiFBKEbYE87/V1sERSDFH6uAO0+5GS7MChg26w54kZeRfO4Nzrwqj ZbrLkjWJLk2TktdvkZwqaiRpn/Cu0ANALocft3bD+gI2aoYHndgi9m2ylD1KOqYteX siqCfjrZ8kVfjYh7PsfBqBRfGTl0CQHcSE2UqD6dAbbgX47pPeLrvXuG5x5Dp0Ln4n 7H7YaPpX/4HKIPs1oOTUJYsCw5Syl/j4HbtAQIdiLQ6Iccwov3+zTQZsBeaiU96pJQ iuH1YRvi3w7fzTFy/pacesE9nssq3TfFIbjhGBiHswZSZBPE4iENNXUQSnIN6t7PEx bXd/T5MfXfOlw== Date: Fri, 11 Mar 2022 18:01:11 -0800 (PST) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Miaoqian Lin cc: Stefano Stabellini , Russell King , Catalin Marinas , Shannon Zhao , Julien Grall , xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm/xen: Fix refcount leak in xen_dt_guest_init In-Reply-To: <20220309102442.14726-1-linmq006@gmail.com> Message-ID: References: <20220309102442.14726-1-linmq006@gmail.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220311_180116_494088_E0E0E543 X-CRM114-Status: GOOD ( 20.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 9 Mar 2022, Miaoqian Lin wrote: > The of_find_compatible_node() function returns a node pointer with > refcount incremented, We should use of_node_put() on it when done > Add the missing of_node_put() to release the refcount. > > Fixes: 9b08aaa3199a ("ARM: XEN: Move xen_early_init() before efi_init()") > Signed-off-by: Miaoqian Lin Thanks for the patch! > --- > arch/arm/xen/enlighten.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c > index ec5b082f3de6..262f45f686b6 100644 > --- a/arch/arm/xen/enlighten.c > +++ b/arch/arm/xen/enlighten.c > @@ -424,6 +424,7 @@ static void __init xen_dt_guest_init(void) > > if (of_address_to_resource(xen_node, GRANT_TABLE_INDEX, &res)) { > pr_err("Xen grant table region is not found\n"); > + of_node_put(xen_node); > return; > } This is adding a call to of_node_put on the error path. Shouldn't it be called also in the non-error path? Also, there is another instance of of_address_to_resource being called in this file (in arch_xen_unpopulated_init), does it make sense to call of_node_put there too? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel