[PATCH AUTOSEL 6.1 10/33] regulator: Fix error checking for debugfs_create_dir

From: Sasha Levin
Date: Wed May 31 2023 - 09:44:40 EST


From: Osama Muhammad <osmtendev@xxxxxxxxx>

[ Upstream commit 2bf1c45be3b8f3a3f898d0756c1282f09719debd ]

This patch fixes the error checking in core.c in debugfs_create_dir.
The correct way to check if an error occurred is 'IS_ERR' inline function.

Signed-off-by: Osama Muhammad <osmtendev@xxxxxxxxx
Suggested-by: Ivan Orlov <ivan.orlov0322@xxxxxxxxx
Link: https://lore.kernel.org/r/20230515172938.13338-1-osmtendev@xxxxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/regulator/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c417eae887b2d..e01cade8be0c7 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5257,7 +5257,7 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
}

rdev->debugfs = debugfs_create_dir(rname, debugfs_root);
- if (!rdev->debugfs) {
+ if (IS_ERR(rdev->debugfs)) {
rdev_warn(rdev, "Failed to create debugfs directory\n");
return;
}
@@ -6179,7 +6179,7 @@ static int __init regulator_init(void)
ret = class_register(&regulator_class);

debugfs_root = debugfs_create_dir("regulator", NULL);
- if (!debugfs_root)
+ if (IS_ERR(debugfs_root))
pr_warn("regulator: Failed to create debugfs directory\n");

#ifdef CONFIG_DEBUG_FS
--
2.39.2