Skip to contentSkip to conversation

drm/msm/hdmi: remove unnecessary NULL check

PATCH Superseded Dan Carpenter 2 participants 2 messages Nov 15, 2022 – Nov 17, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/hdmi: remove unnecessary NULL check

This code was refactored in commit 69a88d8633ec ("drm/msm/hdmi: move resource allocation to probe function") and now the "hdmi" pointer can't be NULL. Checking causes a Smatch warning:

drivers/gpu/drm/msm/hdmi/hdmi.c:141 msm_hdmi_init()
warn: variable dereferenced before check 'hdmi' (see line 119)

---
 drivers/gpu/drm/msm/hdmi/hdmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +1 -2
index 7001fabd0977..4d3fdc806bef 100644
@@ -138,8 +138,7 @@ static int msm_hdmi_init(struct hdmi *hdmi)
 	return 0;
 
 fail:
-	if (hdmi)
-		msm_hdmi_destroy(hdmi);
+	msm_hdmi_destroy(hdmi);
 
 	return ret;
 }
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

This code was refactored in commit 69a88d8633ec ("drm/msm/hdmi: move resource allocation to probe function") and now the "hdmi" pointer can't be NULL. Checking causes a Smatch warning:

drivers/gpu/drm/msm/hdmi/hdmi.c:141 msm_hdmi_init()
warn: variable dereferenced before check 'hdmi' (see line 119)

Can you please add the fixes tag to point to the commit you have referenced in the commit message?

LTGM,

Quoted 18 lines
---
  drivers/gpu/drm/msm/hdmi/hdmi.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +1 -2
index 7001fabd0977..4d3fdc806bef 100644
@@ -138,8 +138,7 @@ static int msm_hdmi_init(struct hdmi *hdmi)
  	return 0;
 
  fail:
-	if (hdmi)
-		msm_hdmi_destroy(hdmi);
+	msm_hdmi_destroy(hdmi);
 
  	return ret;
  }