scsi: megaraid_sas: Fix debugfs error checking
Subsystems (2)
PATCH 1/1 scsi: megaraid_sas: Fix debugfs error checking
The debugfs_create_dir() and debugfs_create_file() functions return ERR_PTR() on error, not NULL. The current null-checks fail to detect errors because ERR_PTR() encodes error codes as non-null pointer values.
Replace the null-checks with IS_ERR() for debugfs_create_dir() and debugfs_create_file() calls to properly handle errors.
Fixes ba53572bf02d ("scsi: megaraid_sas: Export RAID map through debugfs")
Signed-off-by Haotian Zhang <[email protected]>
--- drivers/scsi/megaraid/megaraid_sas_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/megaraid/megaraid_sas_debugfs.c +2 -2
@@ -132,7 +132,7 @@ megasas_setup_debugfs(struct megasas_instance *instance)if (!instance->debugfs_root) { instance->debugfs_root =debugfs_create_dir (name, megasas_debugfs_root); -if (!instance->debugfs_root) { +if (IS_ERR (instance->debugfs_root)) {dev_err (&instance->pdev->dev,"Cannot create per adapter debugfs directory\n" );return ;
@@ -144,7 +144,7 @@ megasas_setup_debugfs(struct megasas_instance *instance)debugfs_create_file (name,S_IRUGO , instance->debugfs_root, instance, &megasas_debugfs_raidmap_fops); -if (!instance->raidmap_dump) { +if (IS_ERR (instance->raidmap_dump)) {dev_err (&instance->pdev->dev,"Cannot create raidmap debugfs file\n" );debugfs_remove (instance->debugfs_root);
Signature · 1 line
2.50.1.windows.1