From: Lee Jones <lee@kernel.org>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Avi Fishman <avifishman70@gmail.com>,
Benjamin Fair <benjaminfair@google.com>,
Eric Liu <liuer@nvidia.com>,
linux-rtc@vger.kernel.org, Medad CChien <ctcchien@nuvoton.com>,
Mia Lin <mimi05633@gmail.com>, Nancy Yuen <yuenn@google.com>,
openbmc@lists.ozlabs.org, Patrick Venture <venture@google.com>,
Tali Perry <tali.perry1@gmail.com>,
Tomer Maimon <tmaimon77@gmail.com>
Subject: [PATCH v2 06/10] rtc: nct3018y: fix clock provider use-after-free and leak on unbind
Date: Wed, 2 Dec 2026 20:22:35 +0000 [thread overview]
Message-ID: <dbb030117caf109fc25f3e5bfcbaa92b360fe300.1796242916.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796242916.git.lee@kernel.org>
nct3018y_clkout_register_clk() registers the CLKOUT clock via
devm_clk_register() but adds the OF clock provider with unmanaged
of_clk_add_provider() and never removes it. When the driver unbinds or
devm_rtc_register_device() fails, devres unregisters and frees struct
clk and nct3018y state while leaving a dangling pointer on the global
of_clk_providers list, leaking the provider entry and OF node reference
and causing a use-after-free on subsequent clock lookups.
Use devm_of_clk_add_hw_provider() so the OF clock provider is removed
automatically before the clock and driver state are released.
Fixes: 5adbaed16cc6 ("rtc: Add NCT3018Y real time clock driver")
Closes: https://sashiko.dev/#/bug/linux-9509654b-12c7-4bd1-b189-f52692af9457
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v1 => v2:
- No changes
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
Cc: Avi Fishman <avifishman70@gmail.com>
Cc: Benjamin Fair <benjaminfair@google.com>
Cc: Eric Liu <liuer@nvidia.com>
Cc: linux-rtc@vger.kernel.org
Cc: Medad CChien <ctcchien@nuvoton.com>
Cc: Mia Lin <mimi05633@gmail.com>
Cc: Nancy Yuen <yuenn@google.com>
Cc: openbmc@lists.ozlabs.org
Cc: Patrick Venture <venture@google.com>
Cc: Tali Perry <tali.perry1@gmail.com>
Cc: Tomer Maimon <tmaimon77@gmail.com>
drivers/rtc/rtc-nct3018y.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-nct3018y.c b/drivers/rtc/rtc-nct3018y.c
index 194ba077363a..caa2b21f4002 100644
--- a/drivers/rtc/rtc-nct3018y.c
+++ b/drivers/rtc/rtc-nct3018y.c
@@ -479,7 +479,8 @@ static struct clk *nct3018y_clkout_register_clk(struct nct3018y *nct3018y)
clk = devm_clk_register(&client->dev, &nct3018y->clkout_hw);
if (!IS_ERR(clk))
- of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ devm_of_clk_add_hw_provider(&client->dev, of_clk_hw_simple_get,
+ &nct3018y->clkout_hw);
return clk;
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-02 20:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 20:22 [PATCH v2 00/10] rtc: assorted bug fixes across RTC drivers Lee Jones
2026-12-02 20:22 ` [PATCH v2 01/10] rtc: rx8025: pass parent I2C device in clock_adjust_ppb sysfs callbacks Lee Jones
2026-12-02 20:22 ` [PATCH v2 02/10] rtc: mt6397: handle non-DT platform device matching in probe Lee Jones
2026-12-02 20:22 ` [PATCH v2 03/10] rtc: ma35d1: allocate RTC device before requesting interrupt Lee Jones
2026-12-02 20:22 ` [PATCH v2 04/10] rtc: mpc5121: get interrupts via platform_get_irq() Lee Jones
2026-12-02 20:22 ` [PATCH v2 05/10] rtc: m41t80: use devm helpers for square-wave clock registration Lee Jones
2026-12-02 20:22 ` Lee Jones [this message]
2026-12-02 20:22 ` [PATCH v2 07/10] rtc: stmp3xxx: unregister child watchdog platform device on unbind Lee Jones
2026-12-02 20:22 ` [PATCH v2 08/10] rtc: ds1685: check driver data for NULL in ds1685_rtc_poweroff() Lee Jones
2026-12-02 20:22 ` [PATCH v2 09/10] rtc: omap: prevent NULL and dangling pointer dereferences in power-off path Lee Jones
2026-12-02 20:22 ` [PATCH v2 10/10] rtc: bq32k: use u8 register buffer in trickle_charge_bypass sysfs Lee Jones
2026-12-02 20:30 ` [PATCH v2 00/10] rtc: assorted bug fixes across RTC drivers sashiko-bot
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=dbb030117caf109fc25f3e5bfcbaa92b360fe300.1796242916.git.lee@kernel.org \
--to=lee@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@codeconstruct.com.au \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=ctcchien@nuvoton.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=liuer@nvidia.com \
--cc=mimi05633@gmail.com \
--cc=openbmc@lists.ozlabs.org \
--cc=stable@vger.kernel.org \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=yuenn@google.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