]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: codecs: hdac_hdmi: Fix incorrect use of list_for_each_entry
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Wed, 15 Apr 2020 16:28:49 +0000 (12:28 -0400)
committerMark Brown <broonie@kernel.org>
Thu, 16 Apr 2020 12:01:33 +0000 (13:01 +0100)
If we don't find any pcm, pcm will point at address at an offset from
the the list head and not a meaningful structure. Fix this by returning
correct pcm if found and NULL if not. Found with coccinelle.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20200415162849.308-1-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/hdac_hdmi.c

index fba9b749839ded0a2684075d4ccdeda6c521584e..f26b77faed5993730b0890a2f5b7069fabb65649 100644 (file)
@@ -142,14 +142,14 @@ static struct hdac_hdmi_pcm *
 hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi,
                           struct hdac_hdmi_cvt *cvt)
 {
-       struct hdac_hdmi_pcm *pcm = NULL;
+       struct hdac_hdmi_pcm *pcm;
 
        list_for_each_entry(pcm, &hdmi->pcm_list, head) {
                if (pcm->cvt == cvt)
-                       break;
+                       return pcm;
        }
 
-       return pcm;
+       return NULL;
 }
 
 static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,