diff mbox series

media: amphion: delete unnecessary NULL check

Message ID 20220606131042.4052393-1-william.xuanziyang@huawei.com (mailing list archive)
State New, archived
Headers show
Series media: amphion: delete unnecessary NULL check | expand

Commit Message

Ziyang Xuan (William) June 6, 2022, 1:10 p.m. UTC
vfree(NULL) is safe. NULL check before vfree() is not needed.
Delete them to simplify the code.

Generated by coccinelle script:
	scripts/coccinelle/free/ifnullfree.cocci

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 drivers/media/platform/amphion/vdec.c     | 3 +--
 drivers/media/platform/amphion/venc.c     | 3 +--
 drivers/media/platform/amphion/vpu_cmds.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

Comments

Ming Qian June 7, 2022, 9:31 a.m. UTC | #1
> From: Ziyang Xuan <william.xuanziyang@huawei.com>
> Sent: 2022年6月6日 21:11
> To: Ming Qian <ming.qian@nxp.com>; Shijie Qin <shijie.qin@nxp.com>; Eagle
> Zhou <eagle.zhou@nxp.com>; mchehab@kernel.org;
> linux-media@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: william.xuanziyang@huawei.com
> Subject: [PATCH] media: amphion: delete unnecessary NULL check
> 
> vfree(NULL) is safe. NULL check before vfree() is not needed.
> Delete them to simplify the code.
> 
> Generated by coccinelle script:
> 	scripts/coccinelle/free/ifnullfree.cocci
> 
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>

Reviewed-by: ming_qian <ming.qian@nxp.com>

> ---
>  drivers/media/platform/amphion/vdec.c     | 3 +--
>  drivers/media/platform/amphion/venc.c     | 3 +--
>  drivers/media/platform/amphion/vpu_cmds.c | 3 +--
>  3 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/amphion/vdec.c
> b/drivers/media/platform/amphion/vdec.c
> index 3c02aa2a54aa..09d4f27970ec 100644
> --- a/drivers/media/platform/amphion/vdec.c
> +++ b/drivers/media/platform/amphion/vdec.c
> @@ -1369,8 +1369,7 @@ static void vdec_cleanup(struct vpu_inst *inst)
>  		return;
> 
>  	vdec = inst->priv;
> -	if (vdec)
> -		vfree(vdec);
> +	vfree(vdec);
>  	inst->priv = NULL;
>  	vfree(inst);
>  }
> diff --git a/drivers/media/platform/amphion/venc.c
> b/drivers/media/platform/amphion/venc.c
> index 43d61d82f58c..461524dd1e44 100644
> --- a/drivers/media/platform/amphion/venc.c
> +++ b/drivers/media/platform/amphion/venc.c
> @@ -919,8 +919,7 @@ static void venc_cleanup(struct vpu_inst *inst)
>  		return;
> 
>  	venc = inst->priv;
> -	if (venc)
> -		vfree(venc);
> +	vfree(venc);
>  	inst->priv = NULL;
>  	vfree(inst);
>  }
> diff --git a/drivers/media/platform/amphion/vpu_cmds.c
> b/drivers/media/platform/amphion/vpu_cmds.c
> index 9b39d77a178d..f4d7ca78a621 100644
> --- a/drivers/media/platform/amphion/vpu_cmds.c
> +++ b/drivers/media/platform/amphion/vpu_cmds.c
> @@ -117,8 +117,7 @@ static void vpu_free_cmd(struct vpu_cmd_t *cmd)  {
>  	if (!cmd)
>  		return;
> -	if (cmd->pkt)
> -		vfree(cmd->pkt);
> +	vfree(cmd->pkt);
>  	vfree(cmd);
>  }
> 
> --
> 2.25.1
diff mbox series

Patch

diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c
index 3c02aa2a54aa..09d4f27970ec 100644
--- a/drivers/media/platform/amphion/vdec.c
+++ b/drivers/media/platform/amphion/vdec.c
@@ -1369,8 +1369,7 @@  static void vdec_cleanup(struct vpu_inst *inst)
 		return;
 
 	vdec = inst->priv;
-	if (vdec)
-		vfree(vdec);
+	vfree(vdec);
 	inst->priv = NULL;
 	vfree(inst);
 }
diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c
index 43d61d82f58c..461524dd1e44 100644
--- a/drivers/media/platform/amphion/venc.c
+++ b/drivers/media/platform/amphion/venc.c
@@ -919,8 +919,7 @@  static void venc_cleanup(struct vpu_inst *inst)
 		return;
 
 	venc = inst->priv;
-	if (venc)
-		vfree(venc);
+	vfree(venc);
 	inst->priv = NULL;
 	vfree(inst);
 }
diff --git a/drivers/media/platform/amphion/vpu_cmds.c b/drivers/media/platform/amphion/vpu_cmds.c
index 9b39d77a178d..f4d7ca78a621 100644
--- a/drivers/media/platform/amphion/vpu_cmds.c
+++ b/drivers/media/platform/amphion/vpu_cmds.c
@@ -117,8 +117,7 @@  static void vpu_free_cmd(struct vpu_cmd_t *cmd)
 {
 	if (!cmd)
 		return;
-	if (cmd->pkt)
-		vfree(cmd->pkt);
+	vfree(cmd->pkt);
 	vfree(cmd);
 }