mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joshua Covington <joshuacov@gmail.com>
To: Jerome Brunet <jbrunet@baylibre.com>
Cc: Joshua Covington <joshuacov@gmail.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <masneyb@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Andrea della Porta <andrea.porta@suse.com>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 1/3] clk: allow a clk_hw to be registered again after unregistering it
Date: Thu,  3 Dec 2026 15:19:54 +0000	[thread overview]
Message-ID: <20261203151954.139565-1-joshuacov@gmail.com> (raw)
In-Reply-To: <179629359981.3767986.8254684000680163977.b4-review@b4>

Hi Jerome,

Thanks for the review.

On Thu, Dec 03, 2026 at 11:26:39AM +0100, Jerome Brunet wrote:
> IMO, the short term solution to the problem explained in this series is to
> stop poisoning the init data in clk_hw. The framework did not allocate the
> data, arguably it should not be wrecking it on purpose or otherwise touch it.
> Just leave it be.
>
> We should however put clear comment/warning that provider driver should NOT
> be using that or count on it being valid.

That works for me, and it will remove the new clk_core member and the
object_is_on_stack() check. So far I have tried it on top of v3, with
__clk_register() no longer clearing hw->init. The tests for registering
again after unregistration and after a failed registration pass. In v4
I will also add to the clk_hw kernel-doc that providers must not use
@init after registration, as it may point to init data that is gone.

The other half of the patch still needs to stay, though. clk_unregister()
leaves hw->core and hw->clk pointing to the clk_core and clk it
releases. Without clearing them, a clk_parent_data.hw reference to an
unregistered clk_hw resolves to the freed clk_core, and KASAN reports a
slab-use-after-free in __clk_register() in the parent test. That part
costs no memory, so I would keep it.

Stephen, the hw->init poisoning was added by 0214f33c4e0e. Are you fine
with dropping it? If so, I will send a v4 that does the above, with the
test for init data on the stack removed.

> The longer term solution would be stop it storing altogther. I think that
> would mean adding a new registration API that takes the init data as parameter
> and provide the clk_hw in return ... them slowly convert everything, then drop it.

Agreed. That is beyond the scope of this fix, and the decision on it is
for you and Stephen.

Thanks,
Joshua

  reply	other threads:[~2026-12-03 15:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 23:17 [PATCH v3 0/3] " Joshua Covington
2026-11-24 23:17 ` [PATCH v3 1/3] " Joshua Covington
2026-12-03 10:26   ` Jerome Brunet
2026-12-03 15:19     ` Joshua Covington [this message]
2026-12-03 16:36       ` Jerome Brunet
2026-12-03 17:42         ` Joshua Covington
2026-12-04  0:48           ` Brian Masney
2026-11-24 23:17 ` [PATCH v3 2/3] clk: tests: add tests for registering a clk_hw again Joshua Covington
2026-11-24 23:17 ` [PATCH v3 3/3] clk: rp1: reset cached rates on probe Joshua Covington
2026-11-25 10:41   ` Andrea della Porta
2026-12-01  2:56 ` [PATCH v3 0/3] clk: allow a clk_hw to be registered again after unregistering it Brian Masney

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=20261203151954.139565-1-joshuacov@gmail.com \
    --to=joshuacov@gmail.com \
    --cc=andrea.porta@suse.com \
    --cc=bmasney+clk@redhat.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jbrunet@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=masneyb@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@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®