Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14dfe0e4 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Greg Kroah-Hartman
Browse files

ASoC: codecs: hdac_hdmi: Fix incorrect use of list_for_each_entry



[ Upstream commit 326b509238171d37402dbe308e154cc234ed1960 ]

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: default avatarAmadeusz 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: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 278a1576
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -148,14 +148,14 @@ static struct hdac_hdmi_pcm *
hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi,
hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi,
			   struct hdac_hdmi_cvt *cvt)
			   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) {
	list_for_each_entry(pcm, &hdmi->pcm_list, head) {
		if (pcm->cvt == cvt)
		if (pcm->cvt == cvt)
			break;
			return pcm;
	}
	}


	return pcm;
	return NULL;
}
}


static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,
static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,