From patchwork Wed Apr 15 16:28:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 193027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90D79C2BA19 for ; Wed, 15 Apr 2020 14:20:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07350206D5 for ; Wed, 15 Apr 2020 14:20:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="vJnKQiJ+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07350206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6C7A03E; Wed, 15 Apr 2020 16:19:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6C7A03E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1586960436; bh=uRTx3Uw3M66GVuY4Xz6as8E0+YmeQonfHmvRks83Q4w=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=vJnKQiJ+bkX/F6iF/m4Wk3DchxddDCwBRqN32fcRwFliLib3q4VMRKgWECqicPCFe 6oi27T/9GHU4YIJZYjLXgSAWd/r39Vp20tCo6up+8awLIfhjIqnl4nzTft5aK6G/4U MSVFuytaR+k1M6jfyc2oyY4Gqzpri/SNCsnKk6gI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D0304F80229; Wed, 15 Apr 2020 16:19:45 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA254F80124; Wed, 15 Apr 2020 16:19:43 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DFD63F80124 for ; Wed, 15 Apr 2020 16:19:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DFD63F80124 IronPort-SDR: 1/V77jipPkDgbNS9R5xDahAPp6FEVLmO0qzr7iWSalqFuGFhHlTxxatQdiKfsUsB0Ai/yZAmnJ oQ6em99i7NDg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2020 07:19:33 -0700 IronPort-SDR: tCWXMGZgkMMQuXn65NPlJ7WtiIo4kNmLnWH+D5xHmPFSJXSZJIu6lHrUh1DqT6oHWa3Y7/lcbz fP85v3z/LaGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,387,1580803200"; d="scan'208";a="242317080" Received: from pi-desktop.igk.intel.com ([10.237.148.102]) by orsmga007.jf.intel.com with ESMTP; 15 Apr 2020 07:19:30 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Liam Girdwood , Mark Brown , Takashi Iwai Subject: [PATCH 1/3] ASoC: codecs: hdac_hdmi: Fix incorrect use of list_for_each_entry Date: Wed, 15 Apr 2020 12:28:49 -0400 Message-Id: <20200415162849.308-1-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- sound/soc/codecs/hdac_hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index fba9b749839d..f26b77faed59 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -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,