Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1425931imk; Mon, 4 Jul 2022 02:51:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLfitAoIABi4mAbq0LMMuV4eQYyMcyn/Ql/DHvUtst3/N239MKE5LRC5XObDggPnw4rcKs X-Received: by 2002:a05:6402:1854:b0:435:7f6e:e553 with SMTP id v20-20020a056402185400b004357f6ee553mr37590297edy.282.1656928272446; Mon, 04 Jul 2022 02:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656928272; cv=none; d=google.com; s=arc-20160816; b=fOGmNdY4nkM6Y3vyNDPTRklxDTazzSXsSSM0pDRg9nsNas/CntfYiUo1wqi2e9uMRI UMTVJTPiyIeyymeJAs7B34I0+WR/MgS1vf0lPzG8Gh6B+DsCKS1X47QWJCKe45Kz8+oK WIjKsKtJvVCBH0yKKPcNK/xxr1zdcNRBKT2kB1zJVlNdIiQ6PcH1ZdboxRVit+c2fB4I tZrD94JM7FckIc2UBxYMgk0kcykLQ4SnOGUBl1GR1j4Okw8R/l6ku8bZjLkh0uRmMJH2 cBS7E91MM6K11ni74D8J25gs8wSNXe2jpXNywlxqvh+9r4Ya5OV7yBRxf73pDF/Uzb8p zP3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=udOjNkxb0zLueh0BVxb8QV/8/ameN6kmSXVq6SAW6vE=; b=BvuqUI4eW+mBP1iuT9AbXIIoy4NU7anNXxbSOw/gTLAvZPLKm86qEiW4JYUeLsvnuh 4LfxZd3qsq8MwlU41wB8EUmuxb/47N3Nmqf3UbT9uCzHUYlfOFvCtp/mTdtJ+gDKs/6N Gq2t8oJdasZT2o1Oz6R629EdY5KthNgWIqu2mqpTJ6IqLqaGkeEMraz8tBd296dUNDxT LxA+aMDm+Cmv4409xZKCaUrYcK2eGyzUHqPan2o8wPyvqFNDKmWU4RHG0Gn5R8JvU4yl n6ykE5t0SoHdMgD687Uk5CO0HOZ4t5HVMJfTkoV949Bx7zoxRBxdlMU/1JUVcxwZeJAF o5/w== 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 y5-20020a170906470500b00722e5507498si489094ejq.75.2022.07.04.02.50.47; Mon, 04 Jul 2022 02:51: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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbiGDJLz (ORCPT + 99 others); Mon, 4 Jul 2022 05:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbiGDJLy (ORCPT ); Mon, 4 Jul 2022 05:11:54 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF61B1D2 for ; Mon, 4 Jul 2022 02:11:53 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lc0P417w8z1L8jd; Mon, 4 Jul 2022 17:09:28 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 4 Jul 2022 17:11:50 +0800 Received: from [10.174.178.174] (10.174.178.174) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 4 Jul 2022 17:11:50 +0800 Subject: Re: [PATCH] bus: hisi_lpc: fix missing platform_device_put() in hisi_lpc_acpi_probe() To: John Garry , CC: , Greg Kroah-Hartman , "Rafael J. Wysocki" References: <20220701094352.2104998-1-yangyingliang@huawei.com> From: Yang Yingliang Message-ID: <98537957-1446-bc2a-4db6-9c66233937f2@huawei.com> Date: Mon, 4 Jul 2022 17:11:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.178.174] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 On 2022/7/4 16:01, John Garry wrote: > On 01/07/2022 10:43, Yang Yingliang wrote: > > + > > Please send any updated version cc'ing Rafael, who kindly offered to > pick up this patch > >> [...] >> @@ -503,13 +503,13 @@ static int hisi_lpc_acpi_probe(struct device >> *hostdev) >>   { >>       struct acpi_device *adev = ACPI_COMPANION(hostdev); >>       struct acpi_device *child; >> +    struct platform_device *pdev; > > nit: please maintain reverse-firtree ordering OK > >>       int ret; >>         /* Only consider the children of the host */ >>       list_for_each_entry(child, &adev->children, node) { >>           const char *hid = acpi_device_hid(child); >>           const struct hisi_lpc_acpi_cell *cell; >> -        struct platform_device *pdev; >>           const struct resource *res; >>           bool found = false; >>           int num_res; >> @@ -571,22 +571,24 @@ static int hisi_lpc_acpi_probe(struct device >> *hostdev) >>             ret = platform_device_add_resources(pdev, res, num_res); >>           if (ret) >> -            goto fail; >> +            goto fail_put_device; >>             ret = platform_device_add_data(pdev, cell->pdata, >>                              cell->pdata_size); >>           if (ret) >> -            goto fail; >> +            goto fail_put_device; >>             ret = platform_device_add(pdev); >>           if (ret) >> -            goto fail; >> +            goto fail_put_device; >>             acpi_device_set_enumerated(child); >>       } >>         return 0; >>   +fail_put_device: >> +    platform_device_put(pdev); > > is this enough? As I see, this invokes platform_device_release(), but > we would still need platform_device_del() to drop the pdev resources. > hisi_lpc_acpi_remove_subdev() calls platform_device_unregister(), so > it seems proper to do that here also. Please check it. The resource allocated in platform_device_add_resources() is inserted by platform_device_add(), if platform_device_add() is not called successfully, freeing the resource in platform_device_release() is enough. > > Thanks, > John > >>   fail: >>       hisi_lpc_acpi_remove(hostdev); >>       return ret; > > .