2023-05-24 17:10:52

by Osama Muhammad

[permalink] [raw]
Subject: [PATCH] adm1266.c: Fix error checking for debugfs_create_dir

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

Signed-off-by: Osama Muhammad <[email protected]>
---
drivers/hwmon/pmbus/adm1266.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
index 1ac2b2f4c570..d88b6115b42e 100644
--- a/drivers/hwmon/pmbus/adm1266.c
+++ b/drivers/hwmon/pmbus/adm1266.c
@@ -340,7 +340,7 @@ static void adm1266_init_debugfs(struct adm1266_data *data)
return;

data->debugfs_dir = debugfs_create_dir(data->client->name, root);
- if (!data->debugfs_dir)
+ if (IS_ERR(data->debugfs_dir))
return;

debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->debugfs_dir,
--
2.34.1



2023-05-24 22:20:41

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] adm1266.c: Fix error checking for debugfs_create_dir

On Wed, May 24, 2023 at 09:54:23PM +0500, Osama Muhammad wrote:
> This patch fixes the error checking in adm1266.c in
> debugfs_create_dir. The correct way to check if an error occurred
> is using 'IS_ERR' inline function.
>
> Signed-off-by: Osama Muhammad <[email protected]>
> ---
> drivers/hwmon/pmbus/adm1266.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
> index 1ac2b2f4c570..d88b6115b42e 100644
> --- a/drivers/hwmon/pmbus/adm1266.c
> +++ b/drivers/hwmon/pmbus/adm1266.c
> @@ -340,7 +340,7 @@ static void adm1266_init_debugfs(struct adm1266_data *data)
> return;
>
> data->debugfs_dir = debugfs_create_dir(data->client->name, root);
> - if (!data->debugfs_dir)
> + if (IS_ERR(data->debugfs_dir))
> return;

Just drop the error check entirely instead. It is not needed.

Thanks,
Guenter

>
> debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->debugfs_dir,