All of lore.kernel.org
 help / color / mirror / Atom feed
From: Myeonghun Pak <mhun512@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Myeonghun Pak <mhun512@gmail.com>,
	Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] rtc: m41t80: clean up watchdog on registration failure
Date: Wed, 29 Jul 2026 11:18:12 +0900	[thread overview]
Message-ID: <20260729021812.49868-1-mhun512@gmail.com> (raw)

The watchdog miscdevice and reboot notifier are registered before the RTC
device. If RTC device registration fails, probe returns without undoing
either registration. The remove callback is not called after probe
failure, leaving callbacks tied to a device whose driver failed to bind.
Those callbacks continue to dereference the file-global save_client.

Unregister the notifier and miscdevice before returning the RTC
registration error.

Fixes: 10d0c768cc6d ("rtc: m41t80: fix race conditions")
Cc: stable@vger.kernel.org
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/rtc/rtc-m41t80.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -1008,8 +1008,15 @@ static int m41t80_probe(struct i2c_client *client)
 #endif
 
 	rc = devm_rtc_register_device(m41t80_data->rtc);
-	if (rc)
+	if (rc) {
+#ifdef CONFIG_RTC_DRV_M41T80_WDT
+		if (m41t80_data->features & M41T80_FEATURE_HT) {
+			unregister_reboot_notifier(&wdt_notifier);
+			misc_deregister(&wdt_dev);
+		}
+#endif
 		return rc;
+	}
 
 	return 0;
 }
-- 
2.50.1

             reply	other threads:[~2026-07-29  2:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  2:18 Myeonghun Pak [this message]
2026-07-29  2:28 ` [PATCH] rtc: m41t80: clean up watchdog on registration failure 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=20260729021812.49868-1-mhun512@gmail.com \
    --to=mhun512@gmail.com \
    --cc=ae878000@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.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 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.