scsi: megaraid_sas: Fix debugfs error checking
Subsystems (2)
PATCH v2 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]>
---
Changes in v2:
-Also fix the check in megasas_init_debugfs().
--- drivers/scsi/megaraid/megaraid_sas_debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/megaraid/megaraid_sas_debugfs.c +3 -3
@@ -102,7 +102,7 @@ static const struct file_operations megasas_debugfs_raidmap_fops = {void megasas_init_debugfs (void ) { megasas_debugfs_root =debugfs_create_dir ("megaraid_sas" ,NULL ); -if (!megasas_debugfs_root) +if (IS_ERR (megasas_debugfs_root))pr_info ("Cannot create debugfs root\n" ); }
@@ -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