From: Dan Carpenter <dan.carpenter@linaro.org>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: Kaushlendra Kumar <kaushlendra.kumar@intel.com>,
gregkh@linuxfoundation.org, dakr@kernel.org, rafael@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch_topology: Fix incorrect error check in topology_parse_cpu_capacity()
Date: Tue, 23 Sep 2025 13:24:41 +0300 [thread overview]
Message-ID: <aNJ1aY0AuATEKjDN@stanley.mountain> (raw)
In-Reply-To: <20250923-spectral-rich-shellfish-3ab26c@sudeepholla>
On Tue, Sep 23, 2025 at 09:40:28AM +0100, Sudeep Holla wrote:
> On Tue, Sep 23, 2025 at 12:55:20PM +0530, Kaushlendra Kumar wrote:
> > Fix incorrect use of PTR_ERR_OR_ZERO() in topology_parse_cpu_capacity()
> > which causes the code to proceed with NULL clock pointers. The current
> > logic uses !PTR_ERR_OR_ZERO(cpu_clk) which evaluates to true for both
> > valid pointers and NULL, leading to potential NULL pointer dereference
> > in clk_get_rate().
> >
> > PTR_ERR_OR_ZERO(cpu_clk) returns:
> > - 0 if cpu_clk is a valid pointer or NULL
> > - error code if cpu_clk is an error pointer
> >
> > Therefore !PTR_ERR_OR_ZERO(cpu_clk) is true for both valid pointers and
> > NULL, causing the code to call clk_get_rate(NULL) when of_clk_get()
> > returns NULL. Replace with IS_ERR_OR_NULL() which correctly identifies
> > only valid pointers, ensuring clk_get_rate() is called only with valid
> > clock objects.
> >
>
> Nice catch, wonder how it survived so long unnoticed.
I don't think of_clk_get() can actually return NULL... It's still worth
fixing but I don't think it affects real life.
regards,
dan carpenter
next prev parent reply other threads:[~2025-09-23 10:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 7:25 [PATCH] arch_topology: Fix incorrect error check in topology_parse_cpu_capacity() Kaushlendra Kumar
2025-09-23 7:46 ` Markus Elfring
2025-09-23 8:50 ` Kumar, Kaushlendra
2025-09-23 8:40 ` Sudeep Holla
2025-09-23 10:24 ` Dan Carpenter [this message]
2025-09-23 10:27 ` Sudeep Holla
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=aNJ1aY0AuATEKjDN@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kaushlendra.kumar@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.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