scsi: ufs: ufs-pci: Check hba->vops in system PM callbacks
Subsystems (2)
PATCH 1/1 scsi: ufs: ufs-pci: Check hba->vops in system PM callbacks
ufshcd_pci_tbl[] defines the Samsung 0xC00C and AMD 0x1B29 PCI IDs with .driver_data set to 0, so ufshcd_pci_probe() leaves hba->vops NULL. Both ufshcd_pci_suspend_prepare() and ufshcd_pci_resume_complete() dereference hba->vops->name without checking hba->vops:
1. System suspend on an AMD 0x1B29 or Samsung 0xC00C host enters the PM prepare phase and calls ufshcd_pci_suspend_prepare().
2. ufshcd_pci_suspend_prepare() evaluates strcmp(hba->vops->name, "intel-pci"), dereferences NULL, and triggers a kernel oops in the suspending task.
Check that hba->vops is non-NULL before reading hba->vops->name in both callbacks so hosts without variant operations use the generic ufshcd_suspend_prepare() and ufshcd_resume_complete() paths.
--- drivers/ufs/host/ufshcd-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ufs/host/ufshcd-pci.c +2 -2
@@ -644,7 +644,7 @@ static int ufshcd_pci_suspend_prepare(struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev); -if (!strcmp (hba->vops->name,"intel-pci" )) +if (hba->vops && !strcmp (hba->vops->name,"intel-pci" ))return ufs_intel_suspend_prepare (dev);return ufshcd_suspend_prepare (dev);
@@ -654,7 +654,7 @@ static void ufshcd_pci_resume_complete(struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev); -if (!strcmp (hba->vops->name,"intel-pci" )) { +if (hba->vops && !strcmp (hba->vops->name,"intel-pci" )) {ufs_intel_resume_complete (dev);return ; }
Signature · 1 line
2.56.0.506.g506a7eabc5-goog
Quoted 12 lines · Stanley Jhu
ufshcd_pci_tbl[] defines the Samsung
0xC00Cand AMD0x1B29PCI IDs with .driver_data set to 0, soufshcd_pci_probe()leaveshba->vopsNULL. Bothufshcd_pci_suspend_prepare()andufshcd_pci_resume_complete()dereferencehba->vops->namewithout checkinghba->vops:1. System suspend on an AMD
0x1B29or Samsung0xC00Chost enters the PM prepare phase and callsufshcd_pci_suspend_prepare().
2.ufshcd_pci_suspend_prepare()evaluatesstrcmp(hba->vops->name, "intel-pci"), dereferences NULL, and triggers a kernel oops in the suspending task.
Quoted 7 lines
Check that
hba->vopsis non-NULL before readinghba->vops->namein both callbacks so hosts without variant operations use the genericufshcd_suspend_prepare()andufshcd_resume_complete()paths.Fixes bb44826c3bdb ("scsi: ufs: ufs-pci: Fix S0ix/S3 for Intel controllers")Signed-off-by Stanley Jhu <[email protected]>
Quoted 26 lines
--- drivers/ufs/host/ufshcd-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ufs/host/ufshcd-pci.c +2
-2@@ -644,7 +644,7 @@ static int ufshcd_pci_suspend_prepare(struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev); -if (!strcmp (hba->vops->name,"intel-pci" )) +if (hba->vops && !strcmp (hba->vops->name,"intel-pci" ))return ufs_intel_suspend_prepare (dev);return ufshcd_suspend_prepare (dev);@@ -654,7 +654,7 @@ static void ufshcd_pci_resume_complete(struct device *dev) {struct ufs_hba *hba =dev_get_drvdata (dev); -if (!strcmp (hba->vops->name,"intel-pci" )) { +if (hba->vops && !strcmp (hba->vops->name,"intel-pci" )) {ufs_intel_resume_complete (dev);return ; }
Quoted 6 lines · Stanley Jhu
ufshcd_pci_tbl[] defines the Samsung
0xC00Cand AMD0x1B29PCI IDs with .driver_data set to 0, soufshcd_pci_probe()leaveshba->vopsNULL. Bothufshcd_pci_suspend_prepare()andufshcd_pci_resume_complete()dereferencehba->vops->namewithout checkinghba->vops:
Quoted 7 lines
1. System suspend on an AMD
0x1B29or Samsung0xC00Chost enters the PM prepare phase and callsufshcd_pci_suspend_prepare().
2.ufshcd_pci_suspend_prepare()evaluatesstrcmp(hba->vops->name, "intel-pci"), dereferences NULL, and triggers a kernel oops in the suspending task.[...]
Applied to 7.4/scsi-fixes, thanks!
[1/1] scsi: ufs: ufs-pci: Check hba->vops in system PM callbacks
https://git.kernel.org/mkp/scsi/c/947d8e9a4d1e
Signature · 1 line
Martin K. Petersen