mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Myeonghun Pak <mhun512@gmail.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] extcon: max77843: cancel the interrupt work after removing the IRQ chip
Date: Thu, 12 Nov 2026 02:03:52 -0500	[thread overview]
Message-ID: <20261112070352.38787-1-mhun512@gmail.com> (raw)

max77843_muic_remove() cancels irq_work before removing the IRQ chip,
so an interrupt can queue it again before the MUIC regmap and driver
data are freed. The probe error path does not cancel the work at all.

Cancel irq_work after regmap_del_irq_chip() stops its producer and
before unregistering the MUIC I2C client. Apply the same ordering to
the probe error path and initialize the work before that path is used.

Found by a static analysis tool under development.

Compile-tested with W=1 for arm64 and x86_64.
Not tested on hardware.

Fixes: 27a28d32b4f2 ("extcon: max77843: Add max77843 MUIC driver")
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>
---

    Based on next-20261109 without Hongyan Xu's cable-detection fix [1].
    The patches conflict textually; if [1] is applied first, keep its
    cancel_delayed_work_sync() at the start of max77843_muic_remove().

    [1] https://lore.kernel.org/all/20260728075429.838-1-getshell@seu.edu.cn/

 drivers/extcon/extcon-max77843.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index c16606b23855..0d45c374fcb4 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -825,6 +825,9 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, info);
 	mutex_init(&info->mutex);
 
+	/* Support virtual irq domain for max77843 MUIC device */
+	INIT_WORK(&info->irq_work, max77843_muic_irq_work);
+
 	/* Initialize i2c and regmap */
 	ret = max77843_init_muic_regmap(max77843);
 	if (ret) {
@@ -879,9 +882,6 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	}
 	dev_info(info->dev, "MUIC device ID : 0x%x\n", id);
 
-	/* Support virtual irq domain for max77843 MUIC device */
-	INIT_WORK(&info->irq_work, max77843_muic_irq_work);
-
 	/* Clear IRQ bits before request IRQs */
 	ret = regmap_bulk_read(max77843->regmap_muic,
 			MAX77843_MUIC_REG_INT1, info->status,
@@ -923,6 +923,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 
 err_muic_irq:
 	regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
+	cancel_work_sync(&info->irq_work);
 	i2c_unregister_device(max77843->i2c_muic);
 
 	return ret;
@@ -933,8 +934,8 @@ static void max77843_muic_remove(struct platform_device *pdev)
 	struct max77843_muic_info *info = platform_get_drvdata(pdev);
 	struct max77693_dev *max77843 = info->max77843;
 
-	cancel_work_sync(&info->irq_work);
 	regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
+	cancel_work_sync(&info->irq_work);
 	i2c_unregister_device(max77843->i2c_muic);
 }
 

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
-- 
2.43.0


                 reply	other threads:[~2026-11-12  7:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261112070352.38787-1-mhun512@gmail.com \
    --to=mhun512@gmail.com \
    --cc=ae878000@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --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®