Linux EDAC development
 help / color / mirror / Atom feed
* [PATCH 1/1] RAS/AMD/FMPM: Fix return value check in setup_debugfs()
@ 2024-10-23  7:05 Zhen Lei
  2024-10-24 15:55 ` Yazen Ghannam
  0 siblings, 1 reply; 3+ messages in thread
From: Zhen Lei @ 2024-10-23  7:05 UTC (permalink / raw)
  To: Yazen Ghannam, Tony Luck, Borislav Petkov, linux-edac; +Cc: Zhen Lei

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


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

end of thread, other threads:[~2024-10-25  1:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23  7:05 [PATCH 1/1] RAS/AMD/FMPM: Fix return value check in setup_debugfs() Zhen Lei
2024-10-24 15:55 ` Yazen Ghannam
2024-10-25  1:34   ` Leizhen (ThunderTown)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox