From: Tristan Madani The driver schedules wq_detcable as a delayed work during probe but never cancels it. If the device is unbound before the work fires, the callback dereferences freed memory because the driver data is managed by devm. Use devm_delayed_work_autocancel() so the work is automatically cancelled when the device is removed, matching the existing irq_work conversion done in the same driver. Fixes: 962e56bfcf0b ("extcon: max14577: Add extcon-max14577 driver to support MUIC device") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- drivers/extcon/extcon-max14577.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 5476f48ed74b9..905722ede7ab1 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -763,7 +763,10 @@ static int max14577_muic_probe(struct platform_device *pdev) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq); + ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable, + max14577_muic_detect_cable_wq); + if (ret) + return ret; queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, delay_jiffies); -- 2.47.3 From: Tristan Madani The driver schedules wq_detcable as a delayed work during probe but never cancels it. If the device is unbound before the work fires, the callback dereferences freed memory because the driver data is managed by devm. Use devm_delayed_work_autocancel() so the work is automatically cancelled when the device is removed, matching the existing irq_work conversion done in the same driver. Fixes: 297620fd1e14 ("extcon: max77693: Check the state/type of cable after boot completed") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- drivers/extcon/extcon-max77693.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 2c567e0b7b7f0..a76084e4d5512 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1251,7 +1251,10 @@ static int max77693_muic_probe(struct platform_device *pdev) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq); + ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable, + max77693_muic_detect_cable_wq); + if (ret) + return ret; queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, delay_jiffies); -- 2.47.3 From: Tristan Madani The driver schedules wq_detcable as a delayed work during probe but never cancels it. If the device is unbound before the work fires, the callback dereferences freed memory because the driver data is managed by devm. Use devm_delayed_work_autocancel() so the work is automatically cancelled when the device is removed, matching the existing irq_work conversion done in the same driver. Fixes: af5eb1a13273 ("extcon: max8997: Use workqueue to check cable state after completing boot of platform") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- drivers/extcon/extcon-max8997.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 9cddf08e06966..7048b9f6d8443 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -754,7 +754,10 @@ static int max8997_muic_probe(struct platform_device *pdev) * After completing the booting of platform, the extcon provider * driver should notify cable state to upper layer. */ - INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq); + ret = devm_delayed_work_autocancel(&pdev->dev, &info->wq_detcable, + max8997_muic_detect_cable_wq); + if (ret) + return ret; queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, delay_jiffies); -- 2.47.3 From: Tristan Madani The driver schedules wq_detcable as a delayed work during probe but the remove callback only tears down the regmap IRQ chip and never cancels it. If the device is unbound before the work fires, the callback dereferences freed memory because the driver data is managed by devm. Use devm_delayed_work_autocancel() so the work is automatically cancelled when the device is removed. Fixes: c03e017c4d3d ("extcon: rt8973a: Add Richtek RT8973A extcon driver") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- drivers/extcon/extcon-rt8973a.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-rt8973a.c b/drivers/extcon/extcon-rt8973a.c index 19bb49f13fb08..184e9f4c16ce3 100644 --- a/drivers/extcon/extcon-rt8973a.c +++ b/drivers/extcon/extcon-rt8973a.c @@ -6,6 +6,7 @@ * Author: Chanwoo Choi */ +#include #include #include #include @@ -635,7 +636,10 @@ static int rt8973a_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, rt8973a_muic_detect_cable_wq); + ret = devm_delayed_work_autocancel(&i2c->dev, &info->wq_detcable, + rt8973a_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 From: Tristan Madani 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 --- 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 */ +#include #include #include #include @@ -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