From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73AC143D4E2; Tue, 21 Jul 2026 22:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672064; cv=none; b=Pwgtgz57+0bdS82tv4MPHtO6gnDLSFS6Hba0yXv0JoA4/pj2gMhjdVTEI/a/cwARqK0KiNzYEZF7tSjRnWu7UtvELT7FVWMWF2YWSYELeFjc7qKWx0I482Q1kzm/5q1Mvox6Z5M6EHK59ud2+ohqdJ0Aj++029BzN63ciIgUVIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672064; c=relaxed/simple; bh=eeWQJErMmOh24zZuVKmkBIFnjF8zvlSlu5EfWuUuGW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mrfLrFSfEZtLr8nungCRFwppApRFws/9U5WNwoCgaTeSw4j6NQJKcO2fC7oepc0vTPGf9iVIoV8s7YW0nclyufwd4nZG1UKZRYlvwffy2j4r2nNRU2+MgL19fipDAr6Cvjx898TB04fjaQ2Lh/SoxY9HFFruyWWaqt4TEtEB6OM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lvTECBz8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lvTECBz8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA0EA1F000E9; Tue, 21 Jul 2026 22:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672063; bh=lK1qqQgkEnYMGmoNnZ55aDa1Z58lWGeyAcby9gSt8rI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lvTECBz8zKQIcWZQ2KFVF6WEXJNMqQhAKPjjppk6VAnuGF0XJ7oc6Skw7dpqs3S9W qP3dUUR6IWEBAX9Vgr/kffzayduEICzUnZs/svurlZ/voH0aVZOoHEba9yTAyIdKyn cQsYtpweZW2kSzko/lYbTRr95AsZztyFTMS038bc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haoxiang Li , Alexandre Belloni , Sasha Levin Subject: [PATCH 5.15 482/843] rtc: cmos: unregister HPET IRQ handler on probe failure Date: Tue, 21 Jul 2026 17:21:57 +0200 Message-ID: <20260721152416.876503886@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haoxiang Li [ Upstream commit a5bb580df018b5d1c5668f05f7979044fb19e23a ] cmos_do_probe() registers cmos_interrupt() as the HPET RTC IRQ handler before requesting the RTC IRQ and registering the RTC device. If either request_irq() or devm_rtc_register_device() fails afterwards, the error path leaves the HPET RTC IRQ handler installed. This leaves a stale handler behind and make a later hpet_register_irq_handler() fail with -EBUSY. Track whether the HPET handler was registered successfully and undo the registration on the probe error path. Also mask the HPET RTC IRQ bits to match the normal shutdown cleanup. Fixes: 9d8af78b0797 ("rtc: add HPET RTC emulation to RTC_DRV_CMOS") Signed-off-by: Haoxiang Li Link: https://patch.msgid.link/20260623100848.2127281-1-haoxiang_li2024@163.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-cmos.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 9f42224aed0592..33642da811817c 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -923,6 +923,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) unsigned char rtc_control; unsigned address_space; u32 flags = 0; + bool hpet_registered = false; struct nvmem_config nvmem_cfg = { .name = "cmos_nvram", .word_size = 1, @@ -1073,6 +1074,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) " failed in rtc_init()."); goto cleanup1; } + hpet_registered = true; } else rtc_cmos_int_handler = cmos_interrupt; @@ -1122,6 +1124,10 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) if (is_valid_irq(rtc_irq)) free_irq(rtc_irq, cmos_rtc.rtc); cleanup1: + if (hpet_registered) { + hpet_mask_rtc_irq_bit(RTC_IRQMASK); + hpet_unregister_irq_handler(cmos_interrupt); + } cmos_rtc.dev = NULL; cleanup0: if (RTC_IOMAPPED) -- 2.53.0