From: Zijun Hu <zijun_hu@icloud.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Zijun Hu <quic_zijuhu@quicinc.com>,
stable@vger.kernel.org
Subject: Re: [PATCH RESEND] PM: domains: Fix return value of API dev_pm_get_subsys_data()
Date: Wed, 13 Nov 2024 20:59:08 +0800 [thread overview]
Message-ID: <0c9a06af-78e2-477d-99a4-b5626a1f791b@icloud.com> (raw)
In-Reply-To: <2024111257-collide-finalist-7a0c@gregkh>
On 2024/11/12 19:46, Greg Kroah-Hartman wrote:
> On Mon, Oct 28, 2024 at 08:31:11PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>
>> dev_pm_get_subsys_data() has below 2 issues under condition
>> (@dev->power.subsys_data != NULL):
>>
>> - it will do unnecessary kzalloc() and kfree().
>
> But that's ok, everything still works, right?
>
i don't think so, as explained below:
under condition (@dev->power.subsys_data != NULL), the API does
not need to do kzalloc() and should always return 0 (success).
but it actually does *unnecessary* kzalloc() and have below impact
shown:
if (kzalloc() is successfully)
it will degrade the API's performance
else
it changed the API's return value to -ENOMEM from 0, that
will impact caller's logic.
>> - it will return -ENOMEM if the kzalloc() fails, that is wrong
>> since the kzalloc() is not needed.
>
> But it's ok to return the proper error if the system is that broken.
> >>
>> Fixed by not doing kzalloc() and returning 0 for the condition.
>>
>> Fixes: ef27bed1870d ("PM: Reference counting of power.subsys_data")
>> Cc: stable@vger.kernel.org
>
> Why is this relevant for stable kernels?
>
it has impact related to performance and logic as explained above.
> thanks,
>
> greg k-h
prev parent reply other threads:[~2024-11-13 12:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 12:31 [PATCH RESEND] PM: domains: Fix return value of API dev_pm_get_subsys_data() Zijun Hu
2024-11-12 11:46 ` Greg Kroah-Hartman
2024-11-12 14:58 ` Zijun Hu
2024-11-13 12:59 ` Zijun Hu [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=0c9a06af-78e2-477d-99a4-b5626a1f791b@icloud.com \
--to=zijun_hu@icloud.com \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=quic_zijuhu@quicinc.com \
--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