All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] elx: efct: fix pointer error checking in debugfs init
@ 2021-06-18 23:30 James Smart
  2021-06-19  2:41 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: James Smart @ 2021-06-18 23:30 UTC (permalink / raw)
  To: linux-scsi; +Cc: ram.vegesna, dan.carpenter, James Smart

debugfs_create_xxx routines, which return pointers, are being checked
for error by looking for NULL values. The routines may return
pointer-munged -Exxx codes, so they should be using IS_ERR() to adapt.

There are two cases:
- the first case is on initial directory creation, which actually
  doesn't need to be checked. So remove the check.
- creation of the sessions subdirectory. Modify this creation to
  create under the initial directory created, and fix failure check.

Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/elx/efct/efct_xport.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/elx/efct/efct_xport.c b/drivers/scsi/elx/efct/efct_xport.c
index 78b6a47599c3..9495cedcc0b9 100644
--- a/drivers/scsi/elx/efct/efct_xport.c
+++ b/drivers/scsi/elx/efct/efct_xport.c
@@ -43,16 +43,13 @@ efct_xport_init_debugfs(struct efct *efct)
 	if (!efct_debugfs_root) {
 		efct_debugfs_root = debugfs_create_dir("efct", NULL);
 		atomic_set(&efct_debugfs_count, 0);
-		if (!efct_debugfs_root) {
-			efc_log_err(efct, "failed to create debugfs entry\n");
-			goto debugfs_fail;
-		}
 	}
 
 	/* Create a directory for sessions in root */
 	if (!efct->sess_debugfs_dir) {
-		efct->sess_debugfs_dir = debugfs_create_dir("sessions", NULL);
-		if (!efct->sess_debugfs_dir) {
+		efct->sess_debugfs_dir = debugfs_create_dir("sessions",
+							efct_debugfs_root);
+		if (IS_ERR(efct->sess_debugfs_dir)) {
 			efc_log_err(efct,
 				    "failed to create debugfs entry for sessions\n");
 			goto debugfs_fail;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] elx: efct: fix pointer error checking in debugfs init
  2021-06-18 23:30 [PATCH] elx: efct: fix pointer error checking in debugfs init James Smart
@ 2021-06-19  2:41 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-06-19  2:41 UTC (permalink / raw)
  To: James Smart; +Cc: linux-scsi, ram.vegesna, dan.carpenter


James,

> debugfs_create_xxx routines, which return pointers, are being checked
> for error by looking for NULL values. The routines may return
> pointer-munged -Exxx codes, so they should be using IS_ERR() to adapt.

Applied to 5.14/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-19  2:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 23:30 [PATCH] elx: efct: fix pointer error checking in debugfs init James Smart
2021-06-19  2:41 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.