summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYihang Li <liyihang9@huawei.com>2024-10-08 10:18:10 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2024-10-15 22:33:34 -0400
commite6702e3919328b24757872cbf7f02c51894624d7 (patch)
treeaf2f737faf93bb2e4014beaa077386958c7db69f
parent9852d85ec9d492ebef56dc5f229416c925758edc (diff)
scsi: hisi_sas: Adjust priority of registering and exiting debugfs for security
To be safe, we should register debugfs at the last stage of driver initialization and then unregister debugfs at the first stage of driver uninstallation. Signed-off-by: Yihang Li <liyihang9@huawei.com> Link: https://lore.kernel.org/r/20241008021822.2617339-2-liyihang9@huawei.com Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_main.c4
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_v3_hw.c17
2 files changed, 8 insertions, 13 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 6219807ce3b9..d3dcc4918444 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -2630,10 +2630,10 @@ static __init int hisi_sas_init(void)
static __exit void hisi_sas_exit(void)
{
- sas_release_transport(hisi_sas_stt);
-
if (hisi_sas_debugfs_enable)
debugfs_remove(hisi_sas_debugfs_dir);
+
+ sas_release_transport(hisi_sas_stt);
}
module_init(hisi_sas_init);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 4cd3a3eab6f1..63a7255d2994 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -4860,16 +4860,13 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
SHOST_DIX_GUARD_CRC);
}
- if (hisi_sas_debugfs_enable)
- debugfs_init_v3_hw(hisi_hba);
-
rc = interrupt_preinit_v3_hw(hisi_hba);
if (rc)
- goto err_out_undo_debugfs;
+ goto err_out_free_host;
rc = scsi_add_host(shost, dev);
if (rc)
- goto err_out_undo_debugfs;
+ goto err_out_free_host;
rc = sas_register_ha(sha);
if (rc)
@@ -4880,6 +4877,8 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_out_unregister_ha;
scsi_scan_host(shost);
+ if (hisi_sas_debugfs_enable)
+ debugfs_init_v3_hw(hisi_hba);
pm_runtime_set_autosuspend_delay(dev, 5000);
pm_runtime_use_autosuspend(dev);
@@ -4900,9 +4899,6 @@ err_out_unregister_ha:
sas_unregister_ha(sha);
err_out_remove_host:
scsi_remove_host(shost);
-err_out_undo_debugfs:
- if (hisi_sas_debugfs_enable)
- debugfs_exit_v3_hw(hisi_hba);
err_out_free_host:
hisi_sas_free(hisi_hba);
scsi_host_put(shost);
@@ -4934,6 +4930,8 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)
struct Scsi_Host *shost = sha->shost;
pm_runtime_get_noresume(dev);
+ if (hisi_sas_debugfs_enable)
+ debugfs_exit_v3_hw(hisi_hba);
sas_unregister_ha(sha);
flush_workqueue(hisi_hba->wq);
@@ -4941,9 +4939,6 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)
hisi_sas_v3_destroy_irqs(pdev, hisi_hba);
hisi_sas_free(hisi_hba);
- if (hisi_sas_debugfs_enable)
- debugfs_exit_v3_hw(hisi_hba);
-
scsi_host_put(shost);
}