diff mbox series

media: amphion: fix error check return value of debugfs_create_file()

Message ID 20220419013809.2561635-1-lv.ruyi@zte.com.cn
State New
Headers show
Series media: amphion: fix error check return value of debugfs_create_file() | expand

Commit Message

Lv Ruyi April 19, 2022, 1:38 a.m. UTC
From: Lv Ruyi <lv.ruyi@zte.com.cn>

If an error occurs, debugfs_create_file() will return ERR_PTR(-ERROR),
so use IS_ERR() to check it.

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
---
 drivers/media/platform/amphion/vpu_dbg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Hans Verkuil April 21, 2022, 11:56 a.m. UTC | #1
On 19/04/2022 03:38, cgel.zte@gmail.com wrote:
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
> 
> If an error occurs, debugfs_create_file() will return ERR_PTR(-ERROR),
> so use IS_ERR() to check it.

Actually, errors should never be checked for debugfs. See e.g. commit
1d8f95c497053839be326bd97eb3128e3b3312cb which removed unnecessary checks
in drivers/media/radio/radio-si476x.c.

Can you make a v2 that removes all the debugfs checks from this driver?

Regards,

	Hans

> 
> Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
>  drivers/media/platform/amphion/vpu_dbg.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
> index 376196bea178..5cef1fd41a74 100644
> --- a/drivers/media/platform/amphion/vpu_dbg.c
> +++ b/drivers/media/platform/amphion/vpu_dbg.c
> @@ -413,7 +413,7 @@ int vpu_inst_create_dbgfs_file(struct vpu_inst *inst)
>  					    vpu->debugfs,
>  					    inst,
>  					    &vpu_dbg_inst_fops);
> -	if (!inst->debugfs) {
> +	if (IS_ERR(inst->debugfs)) {
>  		dev_err(inst->dev, "vpu create debugfs %s fail\n", name);
>  		return -EINVAL;
>  	}
> @@ -451,7 +451,7 @@ int vpu_core_create_dbgfs_file(struct vpu_core *core)
>  						    vpu->debugfs,
>  						    core,
>  						    &vpu_dbg_core_fops);
> -		if (!core->debugfs) {
> +		if (IS_ERR(core->debugfs)) {
>  			dev_err(core->dev, "vpu create debugfs %s fail\n", name);
>  			return -EINVAL;
>  		}
> @@ -463,7 +463,7 @@ int vpu_core_create_dbgfs_file(struct vpu_core *core)
>  							  vpu->debugfs,
>  							  core,
>  							  &vpu_dbg_fwlog_fops);
> -		if (!core->debugfs_fwlog) {
> +		if (IS_ERR(core->debugfs_fwlog)) {
>  			dev_err(core->dev, "vpu create debugfs %s fail\n", name);
>  			return -EINVAL;
>  		}
Lv Ruyi April 22, 2022, 1:51 a.m. UTC | #2
Thanks for your advice, I will send v2 ASAP.

Thanks
Lv Ruyi
diff mbox series

Patch

diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
index 376196bea178..5cef1fd41a74 100644
--- a/drivers/media/platform/amphion/vpu_dbg.c
+++ b/drivers/media/platform/amphion/vpu_dbg.c
@@ -413,7 +413,7 @@  int vpu_inst_create_dbgfs_file(struct vpu_inst *inst)
 					    vpu->debugfs,
 					    inst,
 					    &vpu_dbg_inst_fops);
-	if (!inst->debugfs) {
+	if (IS_ERR(inst->debugfs)) {
 		dev_err(inst->dev, "vpu create debugfs %s fail\n", name);
 		return -EINVAL;
 	}
@@ -451,7 +451,7 @@  int vpu_core_create_dbgfs_file(struct vpu_core *core)
 						    vpu->debugfs,
 						    core,
 						    &vpu_dbg_core_fops);
-		if (!core->debugfs) {
+		if (IS_ERR(core->debugfs)) {
 			dev_err(core->dev, "vpu create debugfs %s fail\n", name);
 			return -EINVAL;
 		}
@@ -463,7 +463,7 @@  int vpu_core_create_dbgfs_file(struct vpu_core *core)
 							  vpu->debugfs,
 							  core,
 							  &vpu_dbg_fwlog_fops);
-		if (!core->debugfs_fwlog) {
+		if (IS_ERR(core->debugfs_fwlog)) {
 			dev_err(core->dev, "vpu create debugfs %s fail\n", name);
 			return -EINVAL;
 		}