Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp890569pxb; Fri, 22 Apr 2022 13:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf+tTYLAHm0wkn9shBJlEjNvL9vZz2a/Vgjbm5NfDg78aQDrkRTZj1xaLOefn3LvfHcZvg X-Received: by 2002:aa7:8dd1:0:b0:50a:d009:1451 with SMTP id j17-20020aa78dd1000000b0050ad0091451mr6749020pfr.64.1650659599941; Fri, 22 Apr 2022 13:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650659599; cv=none; d=google.com; s=arc-20160816; b=X+7VKrwwcYS7Y1BioBd336W810KjwrCgaHI4OfzMC924HYAUBW53yT60bGLI/ahtx1 Ralq0Pn0LyvnfSuBDrPNlX5I2BcMTXJa9VdzuJprvnxa7DeNvMF2nmuAV8Hyr4f9yHae Q5Bot/oS+m5oJYC7IO1ZHuRYnADdzFGQGcPkQHpU4p/RimqIXhPZsv4x/+a2NLBedNWr u/JaLeP8wGXJSceup0w5LhsnfzJeyxbemUbUBbypMPVMCpu0ndqtBXxHlF2diwk9mi8p PGQikxPT0IVu1mkW+JrejMsvDz0SQvwkzJQyMSdaPVKSrKwkahaFQfUnZsofTt7pNF9o IOMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=zrlBN5rvNhuwCRgkDQmcD6nmLtDm6u3xFB7SupAZ+dE=; b=vjwiaFY+eUF9xRwDjH7r5TWDrHjdhEiVOMMBaIHsMgTkPOQ2bfJGMkObdheZd8LNlP 4v/Z5sGeyRSGb0KYxdSULsE1moW2ZDWbC0VnHZLU9YpRbwulc38Ln5X6WFbOBZ7UL1/M rFen7gJ9DJtA3PD8JD//VCRMksh0YyIf9pUnd4Jz22V5KMc7v8AFjwACegt6V4oi3/7X TllDFS+K1sBUoJHbMfih/kIbAlYZjcMlh4taSZ9Jzld9IhVnHOutoCPl2ealsZAx/0Bf 5NkrFv00xCAaR4UGDt+3XO5px+/Md3vjFhbTWcxaqJZUWJTIWfyjN+P9QuLToLPgHeIR wO0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8K3b3ix; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h28-20020a63385c000000b003aa68fdbfdasi9084883pgn.93.2022.04.22.13.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:33:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8K3b3ix; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F167926AEDF; Fri, 22 Apr 2022 12:19:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442961AbiDVAjs (ORCPT + 99 others); Thu, 21 Apr 2022 20:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbiDVAjq (ORCPT ); Thu, 21 Apr 2022 20:39:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E16C3F8A1 for ; Thu, 21 Apr 2022 17:36:54 -0700 (PDT) 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 4AC22B829D0 for ; Fri, 22 Apr 2022 00:36:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 623EDC385A5; Fri, 22 Apr 2022 00:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650587812; bh=q77UrqyhbHNMDbtjl23QSlBQJqBW2qP/oerjc/apOe0=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=O8K3b3ix/Aoq1gJHNVNPUCqoWFQCq5larOk4rtjfKjmMzsI3R228DrK0i5oZVxhnB xMu4yAbbvCnQMv+SNmGHPNiWBehcWGZ/7PwvzIHEWMmbyhRYfJGCfUQ7XMXhNptv3Y Ik1QPXzlX3MVQZhtndW7G0GzqkRrfZlnO6XIotP3waUhFWTeEYl8qJYnSZHK6RmPPJ 63zDZGVx+kWkl9j3jmADIPqrSZPP04Yi0rHW2X8RyGjDPlsaD62ZmLE0Ep4nwKBQ1l N0qjuXKWN9v+PpLfp1PDZWXyOSYbQD1cpPaKDlB8HA14Fgmk0BLSPI2qbtB2xGsa73 zy0oqZI4WmJSQ== Date: Thu, 21 Apr 2022 17:36:50 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop To: Miaoqian Lin cc: Stefano Stabellini , Russell King , Shannon Zhao , Catalin Marinas , Julien Grall , Oleksandr Tyshchenko , Juergen Gross , xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm/xen: Fix some refcount leaks In-Reply-To: <20220420014913.2586-1-linmq006@gmail.com> Message-ID: References: <20220406021905.GA30436@8345e2a12d0c> <20220420014913.2586-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 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 On Wed, 20 Apr 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()") > Fixes: b2371587fe0c ("arm/xen: Read extended regions from DT and init Xen resource") > Signed-off-by: Miaoqian Lin Reviewed-by: Stefano Stabellini Juergen, Boris, I applied the patch to for-linus-5.18 > --- > changes in v2: > - call of_node_put in non-error path in xen_dt_guest_init > - fix same refcount leak error in arch_xen_unpopulated_init > --- > arch/arm/xen/enlighten.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c > index ec5b082f3de6..07eb69f9e7df 100644 > --- a/arch/arm/xen/enlighten.c > +++ b/arch/arm/xen/enlighten.c > @@ -337,12 +337,15 @@ int __init arch_xen_unpopulated_init(struct resource **res) > > if (!nr_reg) { > pr_err("No extended regions are found\n"); > + of_node_put(np); > return -EINVAL; > } > > regs = kcalloc(nr_reg, sizeof(*regs), GFP_KERNEL); > - if (!regs) > + if (!regs) { > + of_node_put(np); > return -ENOMEM; > + } > > /* > * Create resource from extended regions provided by the hypervisor to be > @@ -403,8 +406,8 @@ int __init arch_xen_unpopulated_init(struct resource **res) > *res = &xen_resource; > > err: > + of_node_put(np); > kfree(regs); > - > return rc; > } > #endif > @@ -424,8 +427,10 @@ 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; > } > + of_node_put(xen_node); > xen_grant_frames = res.start; > } > > -- > 2.17.1 >