scsi: mpt3sas: Fix debugfs error checking
Subsystems (2)
PATCH 1/1 scsi: mpt3sas: 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 2b01b293f359 ("scsi: mpt3sas: Capture IOC data for debugging purposes")
Signed-off-by Haotian Zhang <[email protected]>
--- drivers/scsi/mpt3sas/mpt3sas_debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_debugfs.c +3 -3
@@ -99,7 +99,7 @@ static const struct file_operations mpt3sas_debugfs_iocdump_fops = {void mpt3sas_init_debugfs (void ) { mpt3sas_debugfs_root =debugfs_create_dir ("mpt3sas" ,NULL ); -if (!mpt3sas_debugfs_root) +if (IS_ERR (mpt3sas_debugfs_root))pr_info ("mpt3sas: Cannot create debugfs root\n" ); }
@@ -124,7 +124,7 @@ mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc)if (!ioc->debugfs_root) { ioc->debugfs_root =debugfs_create_dir (name, mpt3sas_debugfs_root); -if (!ioc->debugfs_root) { +if (IS_ERR (ioc->debugfs_root)) {dev_err (&ioc->pdev->dev,"Cannot create per adapter debugfs directory\n" );return ;
@@ -134,7 +134,7 @@ mpt3sas_setup_debugfs(struct MPT3SAS_ADAPTER *ioc)snprintf (name,sizeof (name),"ioc_dump" ); ioc->ioc_dump =debugfs_create_file (name,0444 , ioc->debugfs_root, ioc, &mpt3sas_debugfs_iocdump_fops); -if (!ioc->ioc_dump) { +if (IS_ERR (ioc->ioc_dump)) {dev_err (&ioc->pdev->dev,"Cannot create ioc_dump debugfs file\n" );debugfs_remove (ioc->debugfs_root);
Signature · 1 line
2.50.1.windows.1