diff mbox series

i2c: gpio: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()

Message ID 20230831140334.3165918-1-ruanjinjie@huawei.com
State New
Headers show
Series i2c: gpio: Fix the NULL vs IS_ERR() bug for debugfs_create_dir() | expand

Commit Message

Jinjie Ruan Aug. 31, 2023, 2:03 p.m. UTC
Since debugfs_create_dir() returns ERR_PTR and never return NULL, So use
IS_ERR() to check it instead of checking NULL.

Fixes: 14911c6f48ec ("i2c: gpio: add fault injector")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/i2c/busses/i2c-gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andi Shyti Sept. 2, 2023, 8:32 a.m. UTC | #1
Hi Jinjie,

On Thu, Aug 31, 2023 at 10:03:34PM +0800, Jinjie Ruan wrote:
> Since debugfs_create_dir() returns ERR_PTR and never return NULL, So use
> IS_ERR() to check it instead of checking NULL.
> 
> Fixes: 14911c6f48ec ("i2c: gpio: add fault injector")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Thanks,
Andi
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index e5a5b9e8bf2c..5ecf35c4a21f 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -265,12 +265,12 @@  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;
 	}
 
 	priv->debug_dir = debugfs_create_dir(pdev->name, i2c_gpio_debug_dir);
-	if (!priv->debug_dir)
+	if (IS_ERR(priv->debug_dir))
 		return;
 
 	init_completion(&priv->scl_irq_completion);