[PATCH 2/3] amdgpu/dc: kfree already checks for NULL.

Dave Airlie airlied at gmail.com
Tue Oct 3 04:27:14 UTC 2017


From: Dave Airlie <airlied at redhat.com>

Don't bother checking for it.

Found with the cocci ifnullfree.cocci script.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 drivers/gpu/drm/amd/display/dc/basics/vector.c          |  3 +--
 drivers/gpu/drm/amd/display/dc/bios/bios_parser.c       |  7 ++-----
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c      |  7 ++-----
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c       |  3 +--
 drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 11 +++--------
 5 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/basics/vector.c b/drivers/gpu/drm/amd/display/dc/basics/vector.c
index e00fc4db..217b8f1 100644
--- a/drivers/gpu/drm/amd/display/dc/basics/vector.c
+++ b/drivers/gpu/drm/amd/display/dc/basics/vector.c
@@ -130,8 +130,7 @@ struct vector *dal_vector_create(
 void dal_vector_destruct(
 	struct vector *vector)
 {
-	if (vector->container != NULL)
-		kfree(vector->container);
+	kfree(vector->container);
 	vector->count = 0;
 	vector->capacity = 0;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
index 2e003b5..6d2f886 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
@@ -119,11 +119,8 @@ struct dc_bios *bios_parser_create(
 
 static void destruct(struct bios_parser *bp)
 {
-	if (bp->base.bios_local_image)
-		kfree(bp->base.bios_local_image);
-
-	if (bp->base.integrated_info)
-		kfree(bp->base.integrated_info);
+	kfree(bp->base.bios_local_image);
+	kfree(bp->base.integrated_info);
 }
 
 static void bios_parser_destroy(struct dc_bios **dcb)
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
index 0c623b3..3d65e2a 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
@@ -85,11 +85,8 @@ static struct atom_encoder_caps_record *get_encoder_cap_record(
 
 static void destruct(struct bios_parser *bp)
 {
-	if (bp->base.bios_local_image)
-		kfree(bp->base.bios_local_image);
-
-	if (bp->base.integrated_info)
-		kfree(bp->base.integrated_info);
+	kfree(bp->base.bios_local_image);
+	kfree(bp->base.integrated_info);
 }
 
 static void firmware_parser_destroy(struct dc_bios **dcb)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 057bfe6..77b3474 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -159,8 +159,7 @@ void dc_destroy_resource_pool(struct dc  *dc)
 		if (dc->res_pool)
 			dc->res_pool->funcs->destroy(&dc->res_pool);
 
-		if (dc->hwseq)
-			kfree(dc->hwseq);
+		kfree(dc->hwseq);
 	}
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
index 89036af..28e768d 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c
@@ -619,14 +619,9 @@ void dce110_clock_source_destroy(struct clock_source **clk_src)
 
 	dce110_clk_src = TO_DCE110_CLK_SRC(*clk_src);
 
-	if (dce110_clk_src->dp_ss_params)
-		kfree(dce110_clk_src->dp_ss_params);
-
-	if (dce110_clk_src->hdmi_ss_params)
-		kfree(dce110_clk_src->hdmi_ss_params);
-
-	if (dce110_clk_src->dvi_ss_params)
-		kfree(dce110_clk_src->dvi_ss_params);
+	kfree(dce110_clk_src->dp_ss_params);
+	kfree(dce110_clk_src->hdmi_ss_params);
+	kfree(dce110_clk_src->dvi_ss_params);
 
 	kfree(dce110_clk_src);
 	*clk_src = NULL;
-- 
2.9.5



More information about the amd-gfx mailing list