Commit 65c39505 authored by Yihang Li's avatar Yihang Li Committed by Slim6882
Browse files

[Backport]scsi: hisi_sas: Create trigger_dump at the end of the debugfs initialization

mainline inclusion
from mainline-v6.12-rc1
commit 9f564f15f88490b484e02442dc4c4b11640ea172
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBCN9K
CVE: NA
Reference: https://lore.kernel.org/r/20241008021822.2617339-3-liyihang9@huawei.com



------------------------------------------------------------------

In the current debugfs initialization process, the interface
trigger_dump is created first, and then the dump directory is created to
store the register dump information.

The issue is that after the trigger_dump interface is created, users can
access the interface to trigger dump and call
debugfs_create_files_v3_hw().  In debugfs_create_files_v3_hw(), if
.debugfs_dump_dentry is NULL, the file for storing dump information is
created under /sys/kernel/debug, and the memory and information cannot
be released after the driver is uninstalled.

Therefore, the creation of the trigger_dump interface is placed at the
end of debugfs initialization.

Signed-off-by: default avatarYihang Li <liyihang9@huawei.com>
Link: https://lore.kernel.org/r/20241008021822.2617339-3-liyihang9@huawei.com


Reviewed-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSlim6882 <yangjunshuo@huawei.com>
parent e7e48f38
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -4823,11 +4823,6 @@ static void debugfs_init_v3_hw(struct hisi_hba *hisi_hba)

	hisi_hba->debugfs_dir = debugfs_create_dir(dev_name(dev),
						   hisi_sas_debugfs_dir);
	debugfs_create_file("trigger_dump", 0200,
			    hisi_hba->debugfs_dir,
			    hisi_hba,
			    &debugfs_trigger_dump_v3_hw_fops);

	/* create bist structures */
	debugfs_bist_init_v3_hw(hisi_hba);

@@ -4836,6 +4831,10 @@ static void debugfs_init_v3_hw(struct hisi_hba *hisi_hba)

	debugfs_phy_down_cnt_init_v3_hw(hisi_hba);
	debugfs_fifo_init_v3_hw(hisi_hba);
	debugfs_create_file("trigger_dump", 0200,
			    hisi_hba->debugfs_dir,
			    hisi_hba,
			    &debugfs_trigger_dump_v3_hw_fops);
}

static int