Skip to content

Commit a3169b5

Browse files
bluesheep1337Alone0316
authored andcommitted
hwmon: (xgene) Fix use after free bug in xgene_hwmon_remove due to race condition
[ Upstream commit cb090e64cf25602b9adaf32d5dfc9c8bec493cd1 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent dc6c76c commit a3169b5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hwmon/xgene-hwmon.c

+1
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev)
748748
{
749749
struct xgene_hwmon_dev *ctx = platform_get_drvdata(pdev);
750750

751+
cancel_work_sync(&ctx->workq);
751752
hwmon_device_unregister(ctx->hwmon_dev);
752753
kfifo_free(&ctx->async_msg_fifo);
753754
if (acpi_disabled)

0 commit comments

Comments
 (0)