Skip to contentSkip to conversation

drm/msm/dpu: removed logically dead code

PATCH Superseded Ameer Hamza 2 participants 4 messages Dec 3, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dpu: removed logically dead code

Fixed coverity warning by removing the dead code

Addresses-Coverity: 1494147 ("Logically dead code")

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +0 -2
index 185379b18572..75f0c0cee661 100644
@@ -751,8 +751,6 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
 
 fail:
 	DPU_ERROR("failed to create encoder\n");
-	if (phys_enc)
-		dpu_encoder_phys_vid_destroy(phys_enc);
 
 	return ERR_PTR(ret);
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Ameer Hamza

Fixed coverity warning by removing the dead code

Addresses-Coverity: 1494147 ("Logically dead code")

While the patch is correct, remove the 'fail' part completely by moving DPU_ERROR and return statement in place of corresponding goto statements.

Quoted 18 lines
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +0 -2
index 185379b18572..75f0c0cee661 100644
@@ -751,8 +751,6 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
 
  fail:
  	DPU_ERROR("failed to create encoder\n");
-	if (phys_enc)
-		dpu_encoder_phys_vid_destroy(phys_enc);
 
  	return ERR_PTR(ret);
  }
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw

PATCH v2 1/1 drm/msm/dpu: removed logically dead code

Fixed coverity warning by removing the dead code

Addresses-Coverity: 1494147 ("Logically dead code")

---
Changes in v2:
removed the 'fail' part completely by moving DPU_ERROR and return statement in place of corresponding goto statements.

---
 .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c    | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +5 -12
index 185379b18572..ddd9d89cd456 100644
@@ -698,17 +698,17 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
 {
 	struct dpu_encoder_phys *phys_enc = NULL;
 	struct dpu_encoder_irq *irq;
-	int i, ret = 0;
+	int i;
 
 	if (!p) {
-		ret = -EINVAL;
-		goto fail;
+		DPU_ERROR("failed to create encoder due to invalid parameter\n");
+		return ERR_PTR(-EINVAL);
 	}
 
 	phys_enc = kzalloc(sizeof(*phys_enc), GFP_KERNEL);
 	if (!phys_enc) {
-		ret = -ENOMEM;
-		goto fail;
+		DPU_ERROR("failed to create encoder due to memory allocation error\n");
+		return ERR_PTR(-ENOMEM);
 	}
 
 	phys_enc->hw_mdptop = p->dpu_kms->hw_mdp;
@@ -748,11 +748,4 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
 	DPU_DEBUG_VIDENC(phys_enc, "created intf idx:%d\n", p->intf_idx);
 
 	return phys_enc;
-
-fail:
-	DPU_ERROR("failed to create encoder\n");
-	if (phys_enc)
-		dpu_encoder_phys_vid_destroy(phys_enc);
-
-	return ERR_PTR(ret);
 }
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#3 lore raw
Quoted 5 lines · Ameer Hamza

Fixed coverity warning by removing the dead code

Addresses-Coverity: 1494147 ("Logically dead code")

Quoted 48 lines

---
Changes in v2:
removed the 'fail' part completely by moving DPU_ERROR and return statement in place of corresponding goto statements.

---
  .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c    | 17 +++++------------
  1 file changed, 5 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +5 -12
index 185379b18572..ddd9d89cd456 100644
@@ -698,17 +698,17 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
  {
  	struct dpu_encoder_phys *phys_enc = NULL;
  	struct dpu_encoder_irq *irq;
-	int i, ret = 0;
+	int i;
 
  	if (!p) {
-		ret = -EINVAL;
-		goto fail;
+		DPU_ERROR("failed to create encoder due to invalid parameter\n");
+		return ERR_PTR(-EINVAL);
  	}
 
  	phys_enc = kzalloc(sizeof(*phys_enc), GFP_KERNEL);
  	if (!phys_enc) {
-		ret = -ENOMEM;
-		goto fail;
+		DPU_ERROR("failed to create encoder due to memory allocation error\n");
+		return ERR_PTR(-ENOMEM);
  	}
 
  	phys_enc->hw_mdptop = p->dpu_kms->hw_mdp;
@@ -748,11 +748,4 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(
  	DPU_DEBUG_VIDENC(phys_enc, "created intf idx:%d\n", p->intf_idx);
 
  	return phys_enc;
-
-fail:
-	DPU_ERROR("failed to create encoder\n");
-	if (phys_enc)
-		dpu_encoder_phys_vid_destroy(phys_enc);
-
-	return ERR_PTR(ret);
  }
Signature · 2 lines
With best wishes
Dmitry