All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: rafael@kernel.org, Chenyuan Yang <chenyuan0y@gmail.com>,
	sven@svenpeter.dev, j@jannau.net, alyssa@rosenzweig.io,
	neal@gompa.dev, marcan@marcan.st, asahi@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: apple-soc: Fix possible null pointer dereference
Date: Wed, 16 Apr 2025 11:22:01 +0100	[thread overview]
Message-ID: <86v7r4jtiu.wl-maz@kernel.org> (raw)
In-Reply-To: <20250416073420.xrhwnzy22zf6yltm@vireshk-i7>

On Wed, 16 Apr 2025 08:34:20 +0100,
Viresh Kumar <viresh.kumar@linaro.org> wrote:
> 
> On 13-04-25, 11:02, Marc Zyngier wrote:
> > Irrespective of this, it would be good to describe under which
> > circumstances this can occur, because I can't see *how* this can
> > trigger. The policy is directly provided by the core code and provide
> > its association with a cpu, and is never NULL at the point of init.
> > 
> > And if it can trigger, why only fix this one particular case?
> > Dereferences of policy are all over the map, and would be just as
> > wrong.
> > 
> > So while this is not wrong, I don't think this serves any real
> > purpose.
> 
> I have applied such patches in the past, considering the same as good
> practice. But I do understand your inputs.
> 
> And so I tried to see if there is actually a way to trigger this.
> 
> - Platform with two cpufreq policies (freq domains) with one CPU in
>   each of them.
> - Boot the kernel, policies will initialize for both the domains.
> - Hotplug out CPU1, that will remove the policy as well.
> - Call cpufreq_quick_get(1), this will call the ->get() callback for
>   CPU1, for which there is no policy available.
> 
> But this is the case only for drivers with `setpolicy` callback, this
> shouldn't happen on apple-soc.
> 
> I am not sure now if we should just apply this patch to be safe, or
> leave it as is. The cpufreq core may change in the future and call the
> `get` callback for all drivers.

If that's the case, I'd suggest adding a __must_check annotation to
cpufreq_cpu_get_raw() and co. At least we'll get a warning on all
missing uses, fix them in one go, and avoid the constant churn of more
or less correct patches.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

      reply	other threads:[~2025-04-16 10:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-12 16:05 [PATCH] cpufreq: apple-soc: Fix possible null pointer dereference Chenyuan Yang
2025-04-13 10:02 ` Marc Zyngier
2025-04-13 21:31   ` Chenyuan Yang
2025-04-14  6:49     ` Marc Zyngier
2025-04-16  7:34   ` Viresh Kumar
2025-04-16 10:22     ` Marc Zyngier [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=86v7r4jtiu.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=chenyuan0y@gmail.com \
    --cc=j@jannau.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=neal@gompa.dev \
    --cc=rafael@kernel.org \
    --cc=sven@svenpeter.dev \
    --cc=viresh.kumar@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.