Skip to contentSkip to conversation

ASoC: hdac_hdmi: Dereference 'edev' after checking for NULL

PATCH In review Fabio Estevam 3 participants 4 messages Feb 17, 2016

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

PATCH 1/1 ASoC: hdac_hdmi: Dereference 'edev' after checking for NULL

From: Fabio Estevam <[email protected]>

Commit 4a3478debf36 ("ASoC: hdac_hdmi: Add jack reporting") leads to the following Smatch complaint:

sound/soc/codecs/hdac_hdmi.c:971 hdac_hdmi_present_sense()
warn: variable dereferenced before check 'edev' (see line 967)

,so deference 'edev' after checking for NULL.

---
 sound/soc/codecs/hdac_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/hdac_hdmi.c +3 -1
index 36f1200..920af2f 100644
@@ -964,13 +964,15 @@ static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid)
 static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, int repoll)
 {
 	struct hdac_ext_device *edev = pin->edev;
-	struct hdac_hdmi_priv *hdmi = edev->private_data;
+	struct hdac_hdmi_priv *hdmi;
 	struct hdac_hdmi_pcm *pcm;
 	int val;
 
 	if (!edev)
 		return;
 
+	hdmi = edev->private_data;
+
 	pin->repoll_count = repoll;
 
 	pm_runtime_get_sync(&edev->hdac.dev);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 9 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Commit 4a3478debf36 ("ASoC: hdac_hdmi: Add jack reporting") leads to the following Smatch complaint:

sound/soc/codecs/hdac_hdmi.c:971 hdac_hdmi_present_sense()
warn: variable dereferenced before check 'edev' (see line 967)

,so deference 'edev' after checking for NULL.

This NULL check is not required, can be removed.

edev object is expected to be present when the present_sense is called. This is called from places where this edev object is already available.

Regards,
Subhransu

Quoted 31 lines
---
 sound/soc/codecs/hdac_hdmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/hdac_hdmi.c +3 -1
index 36f1200..920af2f 100644
@@ -964,13 +964,15 @@ static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid)
 static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, int repoll)
 {
 	struct hdac_ext_device *edev = pin->edev;
-	struct hdac_hdmi_priv *hdmi = edev->private_data;
+	struct hdac_hdmi_priv *hdmi;
 	struct hdac_hdmi_pcm *pcm;
 	int val;
 
 	if (!edev)
 		return;
 
+	hdmi = edev->private_data;
+
 	pin->repoll_count = repoll;
 
 	pm_runtime_get_sync(&edev->hdac.dev);
Signature · 1 line
1.9.1
maintainer
#2 lore raw
In reply to Fabio Estevam
Quoted 4 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Commit 4a3478debf36 ("ASoC: hdac_hdmi: Add jack reporting") leads to the following Smatch complaint:

This doesn't apply against current code, please check and resend.