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

Message ID f8e4716278b0a6fe7d9e5537715eb21dcd991d1d.1684930647.git.geert+renesas@glider.be
State New
Headers
Series regulator: core: Fix error checking and messages |

Commit Message

Geert Uytterhoeven May 24, 2023, 12:22 p.m. UTC
  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(-)
  

Comments

Mark Brown May 25, 2023, 10:33 a.m. UTC | #1
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 | }
      | ^
  

Patch

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,