Skip to contentSkip to conversation

i2c: gpio: Fix an error check in i2c_gpio_fault_injector_init()

PATCH In review Minjie Du 2 participants 2 messages Jul 13, 2023 – Aug 14, 2023

Subsystems (3)
lore
Share & tools
lore

Minjie Du

author
#0 lore raw

PATCH v4 1/1 i2c: gpio: Fix an error check in i2c_gpio_fault_injector_init()

debugfs_create_dir() function returns an error value embedded in the pointer (PTR_ERR). Evaluate the return value using IS_ERR rather than checking for NULL.

Fixes 14911c6f48ec ("i2c: gpio: add fault injector")
Cc Wolfram Sang <[email protected]>
Cc <[email protected]> # v4.16+

---
v1-v2:
Fix judge typo.
v2-v3:
Add tags.
v3-v4:
Fix log content.

---
 drivers/i2c/busses/i2c-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-gpio.c +1 -1
index e5a5b9e8b..545927b96 100644
@@ -265,7 +265,7 @@ static void i2c_gpio_fault_injector_init(struct platform_device *pdev)
 	 */
 	if (!i2c_gpio_debug_dir) {
 		i2c_gpio_debug_dir = debugfs_create_dir("i2c-fault-injector", NULL);
-		if (!i2c_gpio_debug_dir)
+		if (IS_ERR(i2c_gpio_debug_dir))
 			return;
 	}
 
Signature · 1 line
2.39.0
maintainer
#1 lore raw

drivers/i2c/busses/i2c-gpio.c static void i2c_gpio_fault_injector_init(struct platform_device *pdev) · line 269

Quoted 4 lines
drivers/i2c/busses/i2c-gpio.c +1 -1
-		if (!i2c_gpio_debug_dir)
+		if (IS_ERR(i2c_gpio_debug_dir))
 			return;

AFAIK, the trend is to remove error checking from debugfs calls. It is debug only anyhow. No need to bail out. But please double check.