Re: [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir

From: Daniel Lezcano
Date: Tue May 30 2023 - 11:47:47 EST


On 17/05/2023 18:03, Osama Muhammad wrote:
This patch fixes the error checking in lvts_thermal.c in
debugfs_create_dir. The correct way to check if an error occurred
is 'IS_ERR' inline function.

We do no longer check debugfs functions return values.

eg.

https://www.spinics.net/lists/linux-spi/msg37903.html
https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/


Signed-off-by: Osama Muhammad <osmtendev@xxxxxxxxx>
---
drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index d0a3f95b7884..61386be78fa0 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
int i;
lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
- if (!lvts_td->dom_dentry)
+ if (IS_ERR(lvts_td->dom_dentry))
return 0;
for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
@@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
sprintf(name, "controller%d", i);
dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
- if (!dentry)
+ if (IS_ERR(dentry))
continue;
regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog