From nobody Fri Oct 2 05:31:37 2026 Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [13.75.44.102]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D6A5344DA0; Wed, 5 Aug 2026 05:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.75.44.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785906264; cv=none; b=KQyiNTiVRa5gXi4kQost2/kpBQUxGZYLRZWEsd9I2M98Cvb/mZJJ7tTlpPclPOW7zH87jRT+dRYI7B7pnHGZuqN/MK21gnndxq2cUNma9hDZVQbE1/9yAOUvhDgFMN4E9S+Vv7dHTKkbqMeyts8XJRf0tDarzxclHQQw4yoE7uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785906264; c=relaxed/simple; bh=+fhAsUwYJiOhtmlotdGy0uNDeGZ1rtEymt4el5UYOyc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jwYRuLPTYy4KiMi2mTNUs6Sg1GUayJ7zo45lYJhQqoUx3E4reRgnS3DxKGerOHdhDoFHJIg3JadPdCYunO7aMoUWaxvqLYvrCpzma2D8Rd0peP8xXvzSeCO9jpHZ+lQvVte7Zo98TrQo1XatXBkf4YGzxDZaSxTVRWwAZDuRjp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=13.75.44.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from zju.edu.cn (unknown [10.98.66.117]) by mtasvr (Coremail) with SMTP id _____wDX339MxHJqoeNnAA--.21424S3; Wed, 05 Aug 2026 13:04:13 +0800 (CST) Received: from localhost.localdomain (unknown [10.98.66.117]) by mail-app3 (Coremail) with SMTP id zS_KCgCXrW9MxHJqVOz3Aw--.61898S2; Wed, 05 Aug 2026 13:04:12 +0800 (CST) From: Fan Wu To: myungjoo.ham@samsung.com, cw00.choi@samsung.com Cc: rogerq@ti.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Fan Wu Subject: [PATCH] extcon: usb-gpio: Use devm_delayed_work_autocancel() for detect work Date: Wed, 5 Aug 2026 05:03:16 +0000 Message-Id: <20260805050316.7492-1-fanwu01@zju.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: zS_KCgCXrW9MxHJqVOz3Aw--.61898S2 X-CM-SenderInfo: qrstjiaswqq6lmxovvfxof0/ X-CM-DELIVERINFO: =?B?BkWtVwXKKxbFmtjJiESix3B1w3vZ3A9ovKVTomAyoQazvoRs/NHSP8GI2EvgeEEW7R sfnZPoDCNGYdHSfuFmYJL54WMUUuJhjfBDZmB2hu6dm/pwk6yhHUcJO/R/68FN2XWUy4iM TG79cshhGmOoYPO7ZR3N5RPxYw6l01w8CbPzC/8w X-Coremail-Antispam: 1Uk129KBj93XoW7Zw1fGr47KF13tFyktrWxXwc_yoW8uFW7pF Z5CFyjkrW8CFyrKw1qya18Za45Jws7t34jgrW7tas5ury5Jr18X34SkFy0qFs5JFWkKay3 AFsxXFy8ZF15ZFXCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Gb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AK xVW0oVCq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc804V CY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AK xVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48Icx kI7VAKI48JM4x0Y48IcxkI7VAKI48G6xCjnVAKz4kxMxAIw28IcxkI7VAKI48JMxC20s02 6xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_Jr I_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v2 6r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj4 0_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8 JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8Tv3UUUUUU== Content-Type: text/plain; charset="utf-8" The id/vbus threaded IRQ handler re-arms the detect delayed work on every edge. cancel_delayed_work_sync() in ->remove() runs before the IRQs are freed by devm, so an IRQ firing in between can re-arm the work and run it after info is freed, leading to a use-after-free. The same window exists on probe-error paths. Use devm_delayed_work_autocancel() so devm LIFO order frees the IRQs before the work is cancelled, on every path. Drop the now-redundant cancel from ->remove(). This matches the other extcon drivers. This issue was found by an in-house static analysis tool. Compile-tested only; runtime testing is appreciated. Fixes: e52817faae35 ("extcon: usb-gpio: Introduce gpio usb extcon driver") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.6 Signed-off-by: Fan Wu --- drivers/extcon/extcon-usb-gpio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-g= pio.c index 5e8ad21ad206..4cc42f102098 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -6,6 +6,7 @@ * Author: Roger Quadros */ =20 +#include #include #include #include @@ -146,7 +147,10 @@ static int usb_extcon_probe(struct platform_device *pd= ev) if (ret < 0) info->debounce_jiffies =3D msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS); =20 - INIT_DELAYED_WORK(&info->wq_detcable, usb_extcon_detect_cable); + ret =3D devm_delayed_work_autocancel(dev, &info->wq_detcable, + usb_extcon_detect_cable); + if (ret) + return ret; =20 if (info->id_gpiod) { info->id_irq =3D gpiod_to_irq(info->id_gpiod); @@ -195,9 +199,6 @@ static int usb_extcon_probe(struct platform_device *pde= v) =20 static void usb_extcon_remove(struct platform_device *pdev) { - struct usb_extcon_info *info =3D platform_get_drvdata(pdev); - - cancel_delayed_work_sync(&info->wq_detcable); device_init_wakeup(&pdev->dev, false); } =20 --=20 2.43.0