Linux EDAC development
 help / color / mirror / Atom feed
From: Zhen Lei <thunder.leizhen@huawei.com>
To: Yazen Ghannam <Yazen.Ghannam@amd.com>,
	Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	<linux-edac@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Subject: [PATCH 1/1] RAS/AMD/FMPM: Fix return value check in setup_debugfs()
Date: Wed, 23 Oct 2024 15:05:08 +0800	[thread overview]
Message-ID: <20241023070508.275-1-thunder.leizhen@huawei.com> (raw)

Fix the incorrect return value check for debugfs_create_dir() and
debugfs_create_file(), which returns ERR_PTR(-ERROR) instead of NULL
when it fails. In addition, fmpm_dfs_dir should be set to NULL after
being reclaimed.

Fixes: 7d19eea51757 ("RAS/AMD/FMPM: Add debugfs interface to print record entries")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/ras/amd/fmpm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index 90de737fbc90978..b1cffbde6d319ed 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -956,12 +956,14 @@ static void setup_debugfs(void)
 		return;
 
 	fmpm_dfs_dir = debugfs_create_dir("fmpm", dfs);
-	if (!fmpm_dfs_dir)
+	if (IS_ERR(fmpm_dfs_dir))
 		return;
 
 	fmpm_dfs_entries = debugfs_create_file("entries", 0400, fmpm_dfs_dir, NULL, &fmpm_fops);
-	if (!fmpm_dfs_entries)
+	if (IS_ERR(fmpm_dfs_entries)) {
 		debugfs_remove(fmpm_dfs_dir);
+		fmpm_dfs_dir = NULL;
+	}
 }
 
 static const struct x86_cpu_id fmpm_cpuids[] = {
-- 
2.34.1


             reply	other threads:[~2024-10-23  7:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  7:05 Zhen Lei [this message]
2024-10-24 15:55 ` [PATCH 1/1] RAS/AMD/FMPM: Fix return value check in setup_debugfs() Yazen Ghannam
2024-10-25  1:34   ` Leizhen (ThunderTown)

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=20241023070508.275-1-thunder.leizhen@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=Yazen.Ghannam@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox