[PATCH v2 1/2] regulator: core: Fix more error checking for debugfs_create_dir()

Geert Uytterhoeven posted 2 patches 2 years, 8 months ago
There is a newer version of this series
[PATCH v2 1/2] regulator: core: Fix more error checking for debugfs_create_dir()
Posted by Geert Uytterhoeven 2 years, 8 months ago
In case of failure, debugfs_create_dir() does not return NULL, but an
error pointer.  Most incorrect error checks were fixed, but the one in
create_regulator() was forgotten.

Fix the remaining error check.

Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Split off from "regulator: core: Streamline debugfs operations".
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 698ab7f5004bf6b7..ad8baf65f63e369b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1911,7 +1911,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
 
 	if (err != -EEXIST)
 		regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs);
-	if (!regulator->debugfs) {
+	if (IS_ERR(regulator->debugfs))
 		rdev_dbg(rdev, "Failed to create debugfs directory\n");
 	} else {
 		debugfs_create_u32("uA_load", 0444, regulator->debugfs,
-- 
2.34.1
Re: [PATCH v2 1/2] regulator: core: Fix more error checking for debugfs_create_dir()
Posted by Mark Brown 2 years, 8 months ago
On Wed, May 24, 2023 at 02:22:17PM +0200, Geert Uytterhoeven wrote:
> In case of failure, debugfs_create_dir() does not return NULL, but an
> error pointer.  Most incorrect error checks were fixed, but the one in
> create_regulator() was forgotten.

This breaks the build:

/build/stage/linux/drivers/regulator/core.c:1916:11: error: expected identifier 
or ‘(’ before ‘else’
 1916 |         } else {
      |           ^~~~
/build/stage/linux/drivers/regulator/core.c:1933:9: error: expected identifier o
r ‘(’ before ‘if’
 1933 |         if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_STATUS) &&
      |         ^~
/build/stage/linux/drivers/regulator/core.c:1937:9: error: expected identifier o
r ‘(’ before ‘return’
 1937 |         return regulator;
      |         ^~~~~~
/build/stage/linux/drivers/regulator/core.c:1938:1: error: expected identifier or ‘(’ before ‘}’ token
 1938 | }
      | ^