From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Haoxiang Li <haoxiang_li2024@163.com>
Cc: len.brown@intel.com, pavel@kernel.org, dietmar.eggemann@arm.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] PM: EM: fix an API misuse issue in em_create_pd()
Date: Mon, 3 Mar 2025 13:43:33 +0000 [thread overview]
Message-ID: <7778df43-5169-4d1c-9fe6-44bee39edfc1@arm.com> (raw)
In-Reply-To: <CAJZ5v0g5RJaHeYqiP3khp2vPyVHj0W35ab4gtBJ0R14nhSqa_A@mail.gmail.com>
On 3/3/25 12:38, Rafael J. Wysocki wrote:
> On Mon, Mar 3, 2025 at 4:43 AM Haoxiang Li <haoxiang_li2024@163.com> wrote:
>>
>> Replace kfree() with em_table_free() to free
>> the memory allocated by em_table_alloc().
>
> Ostensibly, this is fixing a problem, but there's no problem described
> above. Please describe it.
Thank Rafael for adding me on CC.
>
>> Fixes: 24e9fb635df2 ("PM: EM: Remove old table")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
>> ---
>> kernel/power/energy_model.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
>> index 3874f0e97651..71b60aa20227 100644
>> --- a/kernel/power/energy_model.c
>> +++ b/kernel/power/energy_model.c
>> @@ -447,7 +447,7 @@ static int em_create_pd(struct device *dev, int nr_states,
>> return 0;
>>
>> free_pd_table:
>> - kfree(em_table);
>> + em_table_free(em_table);
>> free_pd:
>> kfree(pd);
>> return -EINVAL;
>> --
>> 2.25.1
>>
IMO there is no need to use RCU freeing mechanism, since
this table is not used yet. We failed in the initialization
steps, so we can simply call kfree() on that memory.
That 'free_pd_table' goto label is triggered before the call to:
rcu_assign_pointer(pd->em_table, em_table);
IMO this is even dangerous in the patch to abuse RCU free for such case.
Regards,
Lukasz
prev parent reply other threads:[~2025-03-03 13:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 3:43 Haoxiang Li
2025-03-03 12:38 ` Rafael J. Wysocki
2025-03-03 13:43 ` Lukasz Luba [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=7778df43-5169-4d1c-9fe6-44bee39edfc1@arm.com \
--to=lukasz.luba@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=haoxiang_li2024@163.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=stable@vger.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®