From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (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 EF95725A2DD for ; Thu, 6 Aug 2026 06:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996321; cv=none; b=GJakSLtew7kSFBjArQymotGezR0ebwrdVC1VYBfyy7iySWaoeZfl9XZnL2yQd2o8dXj9+rLIovjJATYLPyZhFPryP4aY6Rt6rrh79h+6h4vX5evwGh45Osob7tMgnScn0XBGSd5IocgEJb/Xa2IORa2rQtVHQCv4Z3ZpHAG5w0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785996321; c=relaxed/simple; bh=1l6WYC+kYWH9EyRYDewf693+KokAJw53XdjM5ti5/Gs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GFwa+78pUJZ1N0Ycgb5Uq6ZY/30yjBwkvxpyNnZvhqPG2IjfhaqYkk9F3c27lcZwvx05wVMsScqXu26Br8DQtR0lqoityNSVRjNE5E5JAW4XTcGgTMk1LguK6Umsn10BIB9wl9KGFqpSZcuKSjYIVaQsS2UsCAEHM7ZWRmBtavU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=Hq0KCClB; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="Hq0KCClB" Received: from LAPTOP-99KJFSET (unknown [36.153.54.46]) by smtp.qiye.163.com (Hmail) with ESMTP id 48fb94a10; Thu, 6 Aug 2026 14:05:10 +0800 (GMT+08:00) From: Hongyan Xu To: MyungJoo Ham , Chanwoo Choi Cc: linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, Hongyan Xu Subject: [PATCH] extcon: lc824206xa: cancel work on driver detach Date: Thu, 6 Aug 2026 14:04:56 +0800 Message-ID: <20260806060457.37-1-getshell@seu.edu.cn> X-Mailer: git-send-email 2.50.1.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Tid: 0a9fd5ace79c03a1kunm3bdc39c52892aa X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVlCGksaVkJLTxodHxpNHkseH1YeHw 5VEwETFhoSFyQUDg9ZV1kYEgtZQVlITVVKTkhVTk9VT01ZV1kWGg8SFR0UWUFZT0tIVUpLSEpPSE xVSktLVUpCS0tZBg++ DKIM-Signature: a=rsa-sha256; b=Hq0KCClB4c9pMDyduxmXI2e/rlqVz8k1s3MP2RP3p3DTx4avdADCuXRa4yp1YVPF/QfbIvQn4EaBVs9GNgbQ5z6WmdeJnSj+Y0jqEzK17oq5O6qst2Ul4xBE1+CkjHUvRHw148FEW13ObgMGduHwmzZObQ9Trpv7qsw1dCQWjLE=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=8Xth0KAi9+jJPzyeEeRHqW+ZRy1sAULsjLFRx+HdcT0=; h=date:mime-version:subject:message-id:from; The IRQ handler and probe both queue lc824206xa_work(). The worker accesses driver data and managed extcon, power supply and regulator resources. Without cancellation, it can run after those resources are released on driver detach. Use devm_work_autocancel() after registering the resources used by the worker and before requesting the managed IRQ. Reverse devres release order then frees the IRQ first, cancels the work next and releases its dependencies last. Fixes: 9e1897cb9568 ("extcon: Add LC824206XA microUSB switch driver") Signed-off-by: Hongyan Xu --- drivers/extcon/extcon-lc824206xa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-lc824206xa.c b/drivers/extcon/extcon-lc824206xa.c index 56938748aea8..f4da4942e6fe 100644 --- a/drivers/extcon/extcon-lc824206xa.c +++ b/drivers/extcon/extcon-lc824206xa.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -424,7 +425,6 @@ static int lc824206xa_probe(struct i2c_client *client) return -ENOMEM; data->client = client; - INIT_WORK(&data->work, lc824206xa_work); data->cable = EXTCON_NONE; data->previous_cable = EXTCON_NONE; data->usb_type = POWER_SUPPLY_USB_TYPE_UNKNOWN; @@ -463,6 +463,10 @@ static int lc824206xa_probe(struct i2c_client *client) if (IS_ERR(data->psy)) return dev_err_probe(dev, PTR_ERR(data->psy), "registering power supply\n"); + ret = devm_work_autocancel(dev, &data->work, lc824206xa_work); + if (ret) + return ret; + ret = devm_request_threaded_irq(dev, client->irq, NULL, lc824206xa_irq, IRQF_TRIGGER_LOW | IRQF_ONESHOT, KBUILD_MODNAME, data); -- 2.50.1.windows.1