From: Yang Yingliang <yangyingliang@huawei.com>
To: John Garry <john.garry@huawei.com>, <linux-kernel@vger.kernel.org>
Cc: <andriy.shevchenko@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH] bus: hisi_lpc: fix missing platform_device_put() in hisi_lpc_acpi_probe()
Date: Mon, 4 Jul 2022 17:11:49 +0800 [thread overview]
Message-ID: <98537957-1446-bc2a-4db6-9c66233937f2@huawei.com> (raw)
In-Reply-To: <d393f22f-4cf6-65ec-e24f-49d41b36e6ee@huawei.com>
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;
>
> .
prev parent reply other threads:[~2022-07-04 9:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 9:43 Yang Yingliang
2022-07-04 8:01 ` John Garry
2022-07-04 9:11 ` Yang Yingliang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98537957-1446-bc2a-4db6-9c66233937f2@huawei.com \
--to=yangyingliang@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®