Skip to contentSkip to conversation

scsi: ufs: ensure clk gating work is finished before module unloading

PATCH In review Akinobu Mita 2 participants 2 messages Nov 24, 2014 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: 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.

Cc Vinayak Holikatti <[email protected]>
Cc Dolev Raviv <[email protected]>
Cc Subhash Jadavani <[email protected]>
Cc Yaniv Gardi <[email protected]>
Cc Sujit Reddy Thumma <[email protected]>
Cc Maya Erez <[email protected]>
Cc Sahitya Tummala <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/ufs/ufshcd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
index d18adc4..713420b 100644
@@ -744,6 +744,8 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
 	if (!ufshcd_is_clkgating_allowed(hba))
 		return;
 	device_remove_file(hba->dev, &hba->clk_gating.delay_attr);
+	cancel_work_sync(&hba->clk_gating.ungate_work);
+	cancel_delayed_work_sync(&hba->clk_gating.gate_work);
 }
 
 /* Must be called with host lock acquired */
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw

Looks good to me.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Akinobu Mita
Sent: Sunday, November 23, 2014 9:24 PM
To: [email protected]
Cc: Akinobu Mita; Akinobu Mita; Vinayak Holikatti; Dolev Raviv; Subhash Jadavani; Yaniv Gardi; Sujit Reddy Thumma; Maya Erez; Sahitya Tummala; Christoph Hellwig; James E.J. Bottomley
Subject: [PATCH] scsi: 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.

Cc Vinayak Holikatti <[email protected]>
Cc Dolev Raviv <[email protected]>
Cc Subhash Jadavani <[email protected]>
Cc Yaniv Gardi <[email protected]>
Cc Sujit Reddy Thumma <[email protected]>
Cc Maya Erez <[email protected]>
Cc Sahitya Tummala <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/ufs/ufshcd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd.c index renamed from drivers/scsi/ufs/ufshcd.c +0 -0

d18adc4..713420b 100644

drivers/scsi/ufs/ufshcd.c +2 -0
@@ -744,6 +744,8 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
 	if (!ufshcd_is_clkgating_allowed(hba))
 		return;
 	device_remove_file(hba->dev, &hba->clk_gating.delay_attr);
+	cancel_work_sync(&hba->clk_gating.ungate_work);
+	cancel_delayed_work_sync(&hba->clk_gating.gate_work);
 }
 
 /* Must be called with host lock acquired */

--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html