Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7185205rwb; Tue, 6 Dec 2022 02:18:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ce/TyWZc3lq4MeNQt7d7X/t2qfN/izi3rsOyS3ldsoKLtys87p9mefxlF21vDW1BBQ+hb X-Received: by 2002:a63:ea0d:0:b0:477:e6ef:2ed5 with SMTP id c13-20020a63ea0d000000b00477e6ef2ed5mr46415860pgi.197.1670321901307; Tue, 06 Dec 2022 02:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670321901; cv=none; d=google.com; s=arc-20160816; b=qVzLjmHRJ2qlVcYL5ggrzLcaas35vXyzB9O7SUSFOF0CNZhh1yCfHIjAYSQE4feG69 0cLoqz9wZ6GQyl28hbKnqxDNiiDZqhXs+PfZf5MGbVSgQ0qsTyQV+AEio1HHXkBbbxxw J0ayV8lstJJ4d6hWs/36Nptdxr9hQL+T2W9v3ibdTznbbMPwu0h1DADnPgenLCrl/Ynn i4aKKZNCGcAQb/W8NfDa/EylsTpMW7vMZV/XrYuW4qahu4kXfeUaJWUKBFsVTG1kqmWr ZPHUEfTn6aDxyY6NDAKwZuJkgOIqBBggK4dHNd1B82m3U8Dfex0OGT2sh27GLcAn7KK1 3vgw== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=V4JxMD8hmA1TuKaUnHMPT4csUyyljbe3rokwTT3jxjA=; b=b+7z9BHHAll65htvMBRyIWRlnD202pngOVa2W1DDP6oOxjxXhKxgoCSsikIJ2eq9AO kcjCtZCbmfBEc500DONky28x+cwM2GO8HQOIYOHUPfRbgHdMzHYklQhkA/b+Plgvb9yL X+0RgswKhbM6rAEu24HCYzs8O6al8cG+QEzhieK+RRxfGmQ2vvAeeY95pCo9bQG2ENT2 7ihHIIHOelo9wzpom14obEI3QTi1+OZRwVe3x78k4ok4/NHH5Hl4N835z/Jovbc8Byvz NLV/IKV/gjgN1DhkccotwMQFNKihSFL2aMWUaYh5EuDIVwP7NxwE+AnG8F7zO+QQ3Dg1 zJ0Q== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e27-20020a630f1b000000b00477b10def88si16937997pgl.696.2022.12.06.02.18.11; Tue, 06 Dec 2022 02:18:21 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbiLFJUa (ORCPT + 79 others); Tue, 6 Dec 2022 04:20:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235016AbiLFJT4 (ORCPT ); Tue, 6 Dec 2022 04:19:56 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B16E22B37 for ; Tue, 6 Dec 2022 01:18:06 -0800 (PST) Received: from dggpeml500005.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NRF9Q3V0QzJp6T; Tue, 6 Dec 2022 17:14:34 +0800 (CST) Received: from [10.174.178.155] (10.174.178.155) by dggpeml500005.china.huawei.com (7.185.36.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Dec 2022 17:17:33 +0800 Subject: Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe() To: Ira Weiny CC: , , , , , , , References: <20221203095858.612027-1-liuyongqiang13@huawei.com> From: Yongqiang Liu Message-ID: <03a5fc74-1b16-a0ee-c0a0-b45943f76bf0@huawei.com> Date: Tue, 6 Dec 2022 17:17:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.155] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500005.china.huawei.com (7.185.36.59) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 ?? 2022/12/4 4:49, Ira Weiny ะด??: > On Sat, Dec 03, 2022 at 09:58:58AM +0000, Yongqiang Liu wrote: >> We should always call dax_region_put() whenever devm_create_dev_dax() >> succeed or fail to avoid refcount leak of dax_region. Move the return >> value check after dax_region_put(). > I think dax_region_put is called from dax_region_unregister() automatically on > tear down. Yes, Thanks for your explanation. >> Fixes: c01044cc8191 ("ACPI: HMAT: refactor hmat_register_target_device to hmem_register_device") > I'm also not sure how this patch is related to this fix. > > Ira > >> Signed-off-by: Yongqiang Liu >> --- >> drivers/dax/hmem/hmem.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c >> index 1bf040dbc834..09f5cd7b6c8e 100644 >> --- a/drivers/dax/hmem/hmem.c >> +++ b/drivers/dax/hmem/hmem.c >> @@ -36,12 +36,11 @@ static int dax_hmem_probe(struct platform_device *pdev) >> .size = region_idle ? 0 : resource_size(res), >> }; >> dev_dax = devm_create_dev_dax(&data); >> - if (IS_ERR(dev_dax)) >> - return PTR_ERR(dev_dax); >> >> /* child dev_dax instances now own the lifetime of the dax_region */ >> dax_region_put(dax_region); >> - return 0; >> + >> + return IS_ERR(dev_dax) ? PTR_ERR(dev_dax) : 0; >> } >> >> static int dax_hmem_remove(struct platform_device *pdev) >> -- >> 2.25.1 >> >> > .