From: "lihuisong (C)" <lihuisong@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <lenb@kernel.org>, <linux-acpi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <zhanjie9@hisilicon.com>,
<zhenglifeng1@huawei.com>, <yubowen8@huawei.com>,
<liuyonglong@huawei.com>
Subject: Re: [PATCH] ACPI: processor: idle: Fix resource rollback in acpi_processor_power_init
Date: Thu, 3 Jul 2025 14:23:44 +0800 [thread overview]
Message-ID: <6a35291a-32e8-461e-a0e5-405b7b5d24ce@huawei.com> (raw)
In-Reply-To: <CAJZ5v0gjkZ3a-BwgJxjUJbNwu5E_j9VUUHrR3M=a+KPTA-tZcA@mail.gmail.com>
Hi,
Thanks for your review.
在 2025/7/3 1:42, Rafael J. Wysocki 写道:
> On Thu, Jun 19, 2025 at 8:13 AM Huisong Li <lihuisong@huawei.com> wrote:
>> There are two resource rollback issues in acpi_processor_power_init:
>> 1> Do not unregister acpi_idle_driver when do kzalloc failed.
>> 2> Do not free cpuidle device memory when register cpuidle device failed.
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>> drivers/acpi/processor_idle.c | 24 +++++++++++++++++-------
>> 1 file changed, 17 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
>> index 2c2dc559e0f8..3548ab9dac9e 100644
>> --- a/drivers/acpi/processor_idle.c
>> +++ b/drivers/acpi/processor_idle.c
>> @@ -1392,8 +1392,10 @@ int acpi_processor_power_init(struct acpi_processor *pr)
>> }
>>
>> dev = kzalloc(sizeof(*dev), GFP_KERNEL);
>> - if (!dev)
>> - return -ENOMEM;
>> + if (!dev) {
>> + retval = -ENOMEM;
>> + goto unregister_driver;
> No, unregistering the driver here is pointless.
I don't quite understand why here is pointless. Can you explain it?
>
>> + }
>> per_cpu(acpi_cpuidle_device, pr->id) = dev;
>>
>> acpi_processor_setup_cpuidle_dev(pr, dev);
>> @@ -1402,14 +1404,22 @@ int acpi_processor_power_init(struct acpi_processor *pr)
>> * must already be registered before registering device
>> */
>> retval = cpuidle_register_device(dev);
>> - if (retval) {
>> - if (acpi_processor_registered == 0)
>> - cpuidle_unregister_driver(&acpi_idle_driver);
> Pretty much the same as here.
>
> It would be good to clean up dev here though.
It is ok if above is pointless.
>
>> - return retval;
>> - }
>> + if (retval)
>> + goto free_cpuidle_device;
>> +
>> acpi_processor_registered++;
>> }
>> return 0;
>> +
>> +free_cpuidle_device:
>> + per_cpu(acpi_cpuidle_device, pr->id) = NULL;
>> + kfree(dev);
>> +
>> +unregister_driver:
>> + if (acpi_processor_registered == 0)
>> + cpuidle_unregister_driver(&acpi_idle_driver);
>> +
>> + return retval;
>> }
>>
>> int acpi_processor_power_exit(struct acpi_processor *pr)
>> --
>> 2.33.0
>>
next prev parent reply other threads:[~2025-07-03 6:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 6:13 Huisong Li
2025-06-28 0:54 ` lihuisong (C)
2025-07-02 17:42 ` Rafael J. Wysocki
2025-07-03 6:23 ` lihuisong (C) [this message]
2025-07-03 11:09 ` Rafael J. Wysocki
2025-07-14 1:33 ` lihuisong (C)
2025-07-22 11:05 ` lihuisong (C)
2025-07-22 11:10 ` Rafael J. Wysocki
2025-07-22 11:28 ` lihuisong (C)
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=6a35291a-32e8-461e-a0e5-405b7b5d24ce@huawei.com \
--to=lihuisong@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=rafael@kernel.org \
--cc=yubowen8@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/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®