Message ID | 20240808055400.2784028-1-make24@iscas.ac.cn |
---|---|
State | New |
Headers | show |
Series | scsi: ufs: Add missing check for alloc_ordered_workqueue | expand |
On 8/7/24 10:54 PM, Ma Ke wrote: > As it may return NULL pointer and cause NULL pointer dereference. Add check > for the return value of alloc_ordered_workqueue. > > Cc: stable@vger.kernel.org > Fixes: 10e5e37581fc ("scsi: ufs: Add clock ungating to a separate workqueue") > Signed-off-by: Ma Ke <make24@iscas.ac.cn> > --- > drivers/ufs/core/ufshcd.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index 5e3c67e96956..41842f2cd454 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -2139,6 +2139,8 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) > hba->host->host_no); > hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name, > WQ_MEM_RECLAIM | WQ_HIGHPRI); > + if (!hba->clk_gating.clk_gating_workq) > + return; > > ufshcd_init_clk_gating_sysfs(hba); This patch doesn't solve anything since hba->clk_gating.clk_gating_workq is not used in ufshcd_init_clk_gating() after that workqueue has been created. Additionally, this patch doesn't prevent that the UFS driver will attempt to queue work on hba->clk_gating.clk_gating_workq if allocation of that workqueue fails. If it would be possible to vote on Linux kernel patches, my vote would be -2. Bart.
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 5e3c67e96956..41842f2cd454 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2139,6 +2139,8 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba) hba->host->host_no); hba->clk_gating.clk_gating_workq = alloc_ordered_workqueue(wq_name, WQ_MEM_RECLAIM | WQ_HIGHPRI); + if (!hba->clk_gating.clk_gating_workq) + return; ufshcd_init_clk_gating_sysfs(hba);
As it may return NULL pointer and cause NULL pointer dereference. Add check for the return value of alloc_ordered_workqueue. Cc: stable@vger.kernel.org Fixes: 10e5e37581fc ("scsi: ufs: Add clock ungating to a separate workqueue") Signed-off-by: Ma Ke <make24@iscas.ac.cn> --- drivers/ufs/core/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)