Skip to content

Commit cb090e6

Browse files
bluesheep1337groeck
authored andcommitted
hwmon: (xgene) Fix use after free bug in xgene_hwmon_remove due to race condition
In xgene_hwmon_probe, &ctx->workq is bound with xgene_hwmon_evt_work. Then it will be started. If we remove the driver which will call xgene_hwmon_remove to clean up, there may be unfinished work. The possible sequence is as follows: Fix it by finishing the work before cleanup in xgene_hwmon_remove. CPU0 CPU1 |xgene_hwmon_evt_work xgene_hwmon_remove | kfifo_free(&ctx->async_msg_fifo);| | |kfifo_out_spinlocked |//use &ctx->async_msg_fifo Fixes: 2ca492e ("hwmon: (xgene) Fix crash when alarm occurs before driver probe") Signed-off-by: Zheng Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 48e8186 commit cb090e6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hwmon/xgene-hwmon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev)
761761
{
762762
struct xgene_hwmon_dev *ctx = platform_get_drvdata(pdev);
763763

764+
cancel_work_sync(&ctx->workq);
764765
hwmon_device_unregister(ctx->hwmon_dev);
765766
kfifo_free(&ctx->async_msg_fifo);
766767
if (acpi_disabled)

0 commit comments

Comments
 (0)