mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tristan Madani <tristmd@gmail.com>
To: Chanwoo Choi <cw00.choi@samsung.com>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>
Cc: Kyungmin Park <kyungmin.park@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH 5/5] extcon: sm5502: cancel wq_detcable on driver unbind
Date: Tue, 20 Oct 2026 15:41:19 +0000	[thread overview]
Message-ID: <20261020154119.2568395-6-tristmd@gmail.com> (raw)
In-Reply-To: <20261020154119.2568395-1-tristmd@gmail.com>

From: Tristan Madani <tristan@talencesecurity.com>

sm5502_muic_i2c_probe() schedules a delayed work (wq_detcable) for
post-boot cable state detection but the driver has no .remove callback
and never cancels it.  If the device is unbound before the work fires,
the callback dereferences freed memory.

Use devm_delayed_work_autocancel() so the work is automatically
cancelled when the device is removed.

Fixes: e1954452f500 ("extcon: sm5502: Detect cable state after completing platform booting")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 drivers/extcon/extcon-sm5502.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
index c8c4b9ef72aa1..5257cb3ca2266 100644
--- a/drivers/extcon/extcon-sm5502.c
+++ b/drivers/extcon/extcon-sm5502.c
@@ -6,6 +6,7 @@
  * Author: Chanwoo Choi <cw00.choi@samsung.com>
  */
 
+#include <linux/devm-helpers.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
@@ -763,7 +764,10 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2c)
 	 * After completing the booting of platform, the extcon provider
 	 * driver should notify cable state to upper layer.
 	 */
-	INIT_DELAYED_WORK(&info->wq_detcable, sm5502_muic_detect_cable_wq);
+	ret = devm_delayed_work_autocancel(&i2c->dev, &info->wq_detcable,
+					   sm5502_muic_detect_cable_wq);
+	if (ret)
+		return ret;
 	queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
 			msecs_to_jiffies(DELAY_MS_DEFAULT));
 
-- 
2.47.3


      parent reply	other threads:[~2026-10-20 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 15:41 [PATCH 0/5] extcon: cancel wq_detcable delayed work " Tristan Madani
2026-10-20 15:41 ` [PATCH 1/5] extcon: max14577: cancel wq_detcable " Tristan Madani
2026-10-20 15:41 ` [PATCH 2/5] extcon: max77693: " Tristan Madani
2026-10-20 15:41 ` [PATCH 3/5] extcon: max8997: " Tristan Madani
2026-10-20 15:41 ` [PATCH 4/5] extcon: rt8973a: " Tristan Madani
2026-10-20 15:41 ` Tristan Madani [this message]

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=20261020154119.2568395-6-tristmd@gmail.com \
    --to=tristmd@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=stable@vger.kernel.org \
    --cc=sw0312.kim@samsung.com \
    --cc=tristan@talencesecurity.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

all inboxes | Powered by JetHome®