All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yeqi Fu <asuk4.q@gmail.com>
To: ulf.hansson@linaro.org, CLoehle@hyperstone.com
Cc: Yeqi Fu <asuk4.q@gmail.com>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ivan Orlov <ivan.orlov0322@gmail.com>
Subject: [PATCH] mmc: Fix error checking
Date: Thu, 18 May 2023 00:46:28 +0800	[thread overview]
Message-ID: <20230517164628.365335-1-asuk4.q@gmail.com> (raw)

The functions debugfs_create_dir and debugfs_create_file_unsafe return
ERR_PTR if an error occurs, and the appropriate way to verify for errors
is to use the inline function IS_ERR. The patch will substitute the
null-comparison with IS_ERR.

Signed-off-by: Yeqi Fu <asuk4.q@gmail.com>
Suggested-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 drivers/mmc/core/block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 00c33edb9fb9..507bebc22636 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2908,7 +2908,7 @@ static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 			debugfs_create_file_unsafe("status", 0400, root,
 						   card,
 						   &mmc_dbg_card_status_fops);
-		if (!md->status_dentry)
+		if (IS_ERR(md->status_dentry))
 			return -EIO;
 	}
 
@@ -2916,7 +2916,7 @@ static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 		md->ext_csd_dentry =
 			debugfs_create_file("ext_csd", S_IRUSR, root, card,
 					    &mmc_dbg_ext_csd_fops);
-		if (!md->ext_csd_dentry)
+		if (IS_ERR(md->ext_csd_dentry))
 			return -EIO;
 	}
 
-- 
2.37.2


                 reply	other threads:[~2023-05-17 16:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230517164628.365335-1-asuk4.q@gmail.com \
    --to=asuk4.q@gmail.com \
    --cc=CLoehle@hyperstone.com \
    --cc=ivan.orlov0322@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.