* [PATCH] extcon: rtk-type-c: fix IRQ request and release
@ 2026-11-26 13:29 Thomas Fourier
2026-11-27 22:43 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2026-11-26 13:29 UTC (permalink / raw)
Cc: Thomas Fourier, MyungJoo Ham, Chanwoo Choi, Stanley Chang,
open list:EXTERNAL CONNECTOR SUBSYSTEM (EXTCON)
extcon_rtk_type_c_probe() requests the shared type-C IRQ with
devm_request_irq() and ignores the result, but
extcon_rtk_type_c_remove() releases it with plain free_irq(). The devres
entry is kept, so on unbind devres frees the IRQ a second time. The IRQ
is also requested before the spinlock and the delayed work used by
type_c_detect_irq() are initialized, so an early interrupt can use them
uninitialized.
Request the IRQ once the handler's data is initialized, check the
result, and release it with devm_free_irq().
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
---
drivers/extcon/extcon-rtk-type-c.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
index da0b3fd3676e..a421ce1c4361 100644
--- a/drivers/extcon/extcon-rtk-type-c.c
+++ b/drivers/extcon/extcon-rtk-type-c.c
@@ -1339,9 +1339,6 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
goto err;
}
- ret = devm_request_irq(dev, type_c->irq, type_c_detect_irq,
- IRQF_SHARED, "type_c_detect", type_c);
-
spin_lock_init(&type_c->lock);
type_c->rd_ctrl_gpio_desc = NULL;
@@ -1383,6 +1380,13 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&type_c->delayed_work, host_device_switch);
+ ret = devm_request_irq(dev, type_c->irq, type_c_detect_irq,
+ IRQF_SHARED, "type_c_detect", type_c);
+ if (ret) {
+ dev_err(dev, "Failed to request IRQ %d: %d\n", type_c->irq, ret);
+ goto err;
+ }
+
ret = extcon_rtk_type_c_init(type_c);
if (ret) {
dev_err(dev, "%s failed to init type_c\n", __func__);
@@ -1437,7 +1441,7 @@ static void extcon_rtk_type_c_remove(struct platform_device *pdev)
gpiod_put(type_c->rd_ctrl_gpio_desc);
type_c->rd_ctrl_gpio_desc = NULL;
- free_irq(type_c->irq, type_c);
+ devm_free_irq(dev, type_c->irq, type_c);
}
static const struct type_c_cfg rtd1295_type_c_cfg = {
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] extcon: rtk-type-c: fix IRQ request and release
2026-11-26 13:29 [PATCH] extcon: rtk-type-c: fix IRQ request and release Thomas Fourier
@ 2026-11-27 22:43 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2026-11-27 22:43 UTC (permalink / raw)
To: Thomas Fourier
Cc: MyungJoo Ham, Chanwoo Choi, Stanley Chang,
open list:EXTERNAL CONNECTOR SUBSYSTEM (EXTCON)
On 11/26/2026 10:29 PM, Thomas Fourier wrote:
> extcon_rtk_type_c_probe() requests the shared type-C IRQ with
> devm_request_irq() and ignores the result, but
> extcon_rtk_type_c_remove() releases it with plain free_irq(). The devres
> entry is kept, so on unbind devres frees the IRQ a second time. The IRQ
> is also requested before the spinlock and the delayed work used by
> type_c_detect_irq() are initialized, so an early interrupt can use them
> uninitialized.
>
> Request the IRQ once the handler's data is initialized, check the
> result, and release it with devm_free_irq().
>
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> Fixes: 8a590d7371f0 ("extcon: add Realtek DHC RTD SoC Type-C driver")
> ---
> drivers/extcon/extcon-rtk-type-c.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
> index da0b3fd3676e..a421ce1c4361 100644
> --- a/drivers/extcon/extcon-rtk-type-c.c
> +++ b/drivers/extcon/extcon-rtk-type-c.c
> @@ -1339,9 +1339,6 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
> goto err;
> }
>
> - ret = devm_request_irq(dev, type_c->irq, type_c_detect_irq,
> - IRQF_SHARED, "type_c_detect", type_c);
> -
> spin_lock_init(&type_c->lock);
>
> type_c->rd_ctrl_gpio_desc = NULL;
> @@ -1383,6 +1380,13 @@ static int extcon_rtk_type_c_probe(struct platform_device *pdev)
>
> INIT_DELAYED_WORK(&type_c->delayed_work, host_device_switch);
>
> + ret = devm_request_irq(dev, type_c->irq, type_c_detect_irq,
> + IRQF_SHARED, "type_c_detect", type_c);
> + if (ret) {
> + dev_err(dev, "Failed to request IRQ %d: %d\n", type_c->irq, ret);
> + goto err;
> + }
> +
> ret = extcon_rtk_type_c_init(type_c);
> if (ret) {
> dev_err(dev, "%s failed to init type_c\n", __func__);
> @@ -1437,7 +1441,7 @@ static void extcon_rtk_type_c_remove(struct platform_device *pdev)
> gpiod_put(type_c->rd_ctrl_gpio_desc);
> type_c->rd_ctrl_gpio_desc = NULL;
>
> - free_irq(type_c->irq, type_c);
> + devm_free_irq(dev, type_c->irq, type_c);
> }
>
> static const struct type_c_cfg rtd1295_type_c_cfg = {
Applied it. Thanks.
--
Best Regards,
Chanwoo Choi
Principal Engineer, Samsung Electronics
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 22:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 13:29 [PATCH] extcon: rtk-type-c: fix IRQ request and release Thomas Fourier
2026-11-27 22:43 ` Chanwoo Choi
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®