Skip to content

Commit 97cd680

Browse files
mitaChristoph Hellwig
authored andcommitted
ufs: ensure clk gating work is finished before module unloading
When dynamic clk gating feature is enabled, delayed workqueue machanism is used in order to detect certain period of inactivity. But there is no guarantee that scheduled gating work is completed before module unloading. So it can cause kernel crash by accessing memory after it was freed. Fix it by cancelling clk gating and ungating works and ensure that its execution is finished before module unloading. Signed-off-by: Akinobu Mita <[email protected]> Reviewed-by: Subhash Jadavani <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent e8cb64d commit 97cd680

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
744744
if (!ufshcd_is_clkgating_allowed(hba))
745745
return;
746746
device_remove_file(hba->dev, &hba->clk_gating.delay_attr);
747+
cancel_work_sync(&hba->clk_gating.ungate_work);
748+
cancel_delayed_work_sync(&hba->clk_gating.gate_work);
747749
}
748750

749751
/* Must be called with host lock acquired */

0 commit comments

Comments
 (0)