Linux I2C development
 help / color / mirror / Atom feed
* [PATCH] macintosh: therm_windtunnel: Fix i2c adapter reference leak in probe
@ 2026-11-25  9:03 Yige Jiang
  2026-11-25 11:06 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Yige Jiang @ 2026-11-25  9:03 UTC (permalink / raw)
  To: Madhavan Srinivasan
  Cc: Yige Jiang, Michael Ellerman, Wolfram Sang, linuxppc-dev,
	linux-i2c, linux-kernel, stable

therm_of_probe() walks the i2c adapters with i2c_get_adapter() and
drops each reference with i2c_put_adapter() before taking the next one.
Once do_attach() has started the control loop, however, it returns 0
while still holding the reference to the current adapter. The pointer
is not stored anywhere, so that reference is never dropped. This
happens on every successful probe, including after an unbind/rebind of
the platform device, and the extra device reference would make
i2c_del_adapter() for that bus wait forever for the adapter device to
be released.

The driver does not use the adapter after do_attach() returns; the
sensor clients it talks to afterwards are children of the adapter and
are unregistered by i2c_del_adapter(). Drop the reference right after
do_attach(), before checking x.running.

Fixes: 3e7bed52719d ("macintosh: therm_windtunnel: drop using attach_adapter")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: powerpc (ppc32), GCC 14.2.0, W=1, pmac32_defconfig with CONFIG_THERM_WINDTUNNEL=m, CONFIG_I2C_POWERMAC=y (object only; no new warnings).
No hardware or runtime test was performed.
AI assistance was used for analysis and patch preparation.
Runs on every successful probe of the Windtunnel G4 (PowerMac3,6) fan controller, and again on each unbind/rebind.

 drivers/macintosh/therm_windtunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 0b2e08a1bee0..4f2581d9dec9 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -472,9 +472,9 @@ static int therm_of_probe(struct platform_device *dev)
 	/* We assume Macs have consecutive I2C bus numbers starting at 0 */
 	while (adap) {
 		do_attach(adap);
+		i2c_put_adapter(adap);
 		if (x.running)
 			return 0;
-		i2c_put_adapter(adap);
 		adap = i2c_get_adapter(++i);
 	}
 

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:03 [PATCH] macintosh: therm_windtunnel: Fix i2c adapter reference leak in probe Yige Jiang
2026-11-25 11:06 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox