diff mbox series

drm/amd/display: remove no need NULL check before kfree

Message ID 20211116014752.26868-1-bernard@vivo.com (mailing list archive)
State New, archived
Headers show
Series drm/amd/display: remove no need NULL check before kfree | expand

Commit Message

Bernard Zhao Nov. 16, 2021, 1:47 a.m. UTC
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 .../drm/amd/display/dc/dcn10/dcn10_resource.c  | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Alex Deucher Nov. 17, 2021, 9:37 p.m. UTC | #1
Applied.  Thanks!

On Mon, Nov 15, 2021 at 8:48 PM Bernard Zhao <bernard@vivo.com> wrote:
>
> This change is to cleanup the code a bit.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  .../drm/amd/display/dc/dcn10/dcn10_resource.c  | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> index f37551e00023..0090550d4aee 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
> @@ -978,10 +978,8 @@ static void dcn10_resource_destruct(struct dcn10_resource_pool *pool)
>                 pool->base.mpc = NULL;
>         }
>
> -       if (pool->base.hubbub != NULL) {
> -               kfree(pool->base.hubbub);
> -               pool->base.hubbub = NULL;
> -       }
> +       kfree(pool->base.hubbub);
> +       pool->base.hubbub = NULL;
>
>         for (i = 0; i < pool->base.pipe_count; i++) {
>                 if (pool->base.opps[i] != NULL)
> @@ -1011,14 +1009,10 @@ static void dcn10_resource_destruct(struct dcn10_resource_pool *pool)
>         for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
>                 if (pool->base.engines[i] != NULL)
>                         dce110_engine_destroy(&pool->base.engines[i]);
> -               if (pool->base.hw_i2cs[i] != NULL) {
> -                       kfree(pool->base.hw_i2cs[i]);
> -                       pool->base.hw_i2cs[i] = NULL;
> -               }
> -               if (pool->base.sw_i2cs[i] != NULL) {
> -                       kfree(pool->base.sw_i2cs[i]);
> -                       pool->base.sw_i2cs[i] = NULL;
> -               }
> +               kfree(pool->base.hw_i2cs[i]);
> +               pool->base.hw_i2cs[i] = NULL;
> +               kfree(pool->base.sw_i2cs[i]);
> +               pool->base.sw_i2cs[i] = NULL;
>         }
>
>         for (i = 0; i < pool->base.audio_count; i++) {
> --
> 2.33.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index f37551e00023..0090550d4aee 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -978,10 +978,8 @@  static void dcn10_resource_destruct(struct dcn10_resource_pool *pool)
 		pool->base.mpc = NULL;
 	}
 
-	if (pool->base.hubbub != NULL) {
-		kfree(pool->base.hubbub);
-		pool->base.hubbub = NULL;
-	}
+	kfree(pool->base.hubbub);
+	pool->base.hubbub = NULL;
 
 	for (i = 0; i < pool->base.pipe_count; i++) {
 		if (pool->base.opps[i] != NULL)
@@ -1011,14 +1009,10 @@  static void dcn10_resource_destruct(struct dcn10_resource_pool *pool)
 	for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
 		if (pool->base.engines[i] != NULL)
 			dce110_engine_destroy(&pool->base.engines[i]);
-		if (pool->base.hw_i2cs[i] != NULL) {
-			kfree(pool->base.hw_i2cs[i]);
-			pool->base.hw_i2cs[i] = NULL;
-		}
-		if (pool->base.sw_i2cs[i] != NULL) {
-			kfree(pool->base.sw_i2cs[i]);
-			pool->base.sw_i2cs[i] = NULL;
-		}
+		kfree(pool->base.hw_i2cs[i]);
+		pool->base.hw_i2cs[i] = NULL;
+		kfree(pool->base.sw_i2cs[i]);
+		pool->base.sw_i2cs[i] = NULL;
 	}
 
 	for (i = 0; i < pool->base.audio_count; i++) {