From patchwork Thu Mar 31 21:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 555290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D4AFDC433EF for ; Thu, 31 Mar 2022 21:53:54 +0000 (UTC) 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 5A90818B3; Thu, 31 Mar 2022 23:53:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5A90818B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1648763632; bh=EQRewMTWyC0lEdt06pNixKtOWcJ7HxDKBWM4ByZP0Yk=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=vQHfyPvOc/HeNd2AA6uGBRUh06dkFmx/vXnKS+banOD0JtODVAlAUYi/cOJvu1/TV seg8BqCsIt9xYGgP21k037E8tj/hd/DySVa9yp9w1YOzin1d+FiXscJMq28GziMA73 yLNxB9bUFjx/ChCxkYlrob9oxbhmgqimLlUCThQI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D882DF80100; Thu, 31 Mar 2022 23:53:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 197A9F80238; Thu, 31 Mar 2022 23:53:00 +0200 (CEST) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 28422F800E4 for ; Thu, 31 Mar 2022 23:52:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 28422F800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lTyVqB+Z" Received: by mail-ej1-x62f.google.com with SMTP id c10so1958860ejs.13 for ; Thu, 31 Mar 2022 14:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s7WvWGnp8e2+ZYg4JNgLcns/TOfiaFHz5BOyp+VBRH4=; b=lTyVqB+Zc0e84QnpugtFoYsU6sl7K9xjMJMkDzI/2MY0BSJekhavkyJQoQveEAWCdU U/29yUBVpmdYDctiBtXhoEYWP97aqmJaRfvJx/8zju1ldkj8caD+VGEQPmdRLcJPDfN3 TzTBYCAxHgI0B99roIcLtlO2DXlv/SBgb11EHj0mpaudvCBRHBjt5HznTGbG92ak7BsM G6+xpDaBUobsstl3W8YTkgsQgbjsRot9Mkm4cRA8sWE2qbZPxCRxM6BqHi6Y/Tegc2Xa etQ78axO6I3D6qHS40dFndrk8PBpMN7wIudlaPGoTn/5TpyC4bAis2zdx9DTjQURPGeZ AR7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s7WvWGnp8e2+ZYg4JNgLcns/TOfiaFHz5BOyp+VBRH4=; b=6bIxfWOmvpa3j8dO1mpDquSm+MzG4vaLyFoBfWrp22O10B8bQJm1ipW3IdTm3IMNqx sB5jpqeTLdhlGA+IbRbgP9WXe89otynuPZQWc6V8lLJPAIbjI4jstMpw3UicXa6/zXhb 0MXjtnUiSeJ03Vtr5gFp5WUBYuDPVdzqWv4luxgDFnr0s6OHTAfhUIEeCT8HAqB4MDoy +gym5E7nZL6ScPVWA904Dl+LymGZcXrYNIDi/R8fKcmfMWdtDMBexthIGOgBSlKfODK3 Iq3aPPrxfo9SlKSsqt//odjTghnQGetc5NV0/fEkzWhHB4RNBIxf4KoJ0mFs1J1iBAPm NnxA== X-Gm-Message-State: AOAM532WVHdqVpMxuHpu6I0t87TZSEBySy9wXxlsLuDxktTQ+oyQqoRX zAp0os+8Jp8lP5lPnlcsbyE= X-Google-Smtp-Source: ABdhPJwI7ID3mvkG8QYmKxcyThluj0R006fho7SSsOjVN+yoz3BWnxu+1Aod9ibwGRMZdf+o4SIDLg== X-Received: by 2002:a17:906:e4c:b0:6e0:b002:2b2e with SMTP id q12-20020a1709060e4c00b006e0b0022b2emr6627609eji.690.1648763575022; Thu, 31 Mar 2022 14:52:55 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id g20-20020aa7c594000000b004194b07bbfasm299980edq.10.2022.03.31.14.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:52:54 -0700 (PDT) From: Jakob Koschel To: Codrin Ciubotariu Subject: [PATCH 1/3] ASoC: Intel: catpt: remove check of list iterator against head past the loop body Date: Thu, 31 Mar 2022 23:50:01 +0200 Message-Id: <20220331215003.882143-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Cezary Rojewski , Jie Yang , Alexandre Belloni , Takashi Iwai , Liam Girdwood , Cristiano Giuffrida , Chunyan Zhang , Pierre-Louis Bossart , "Bos, H.J." , Yang Yingliang , Orson Zhai , Arnd Bergmann , Nicolas Ferre , Brian Johannesmeyer , Mark Brown , Jakob Koschel , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Baolin Wang , Claudiu Beznea , Mike Rapoport 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" When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will be a bogus pointer computed based on the head element. While it is safe to use the pointer to determine if it was computed based on the head element, either with list_entry_is_head() or &pos->member == head, using the iterator variable after the loop should be avoided. In preparation to limiting the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Reviewed-by: Baolin Wang Acked-by: Cezary Rojewski --- sound/soc/intel/catpt/pcm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275 diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c index a26000cd5ceb..b103b2d4026e 100644 --- a/sound/soc/intel/catpt/pcm.c +++ b/sound/soc/intel/catpt/pcm.c @@ -330,7 +330,8 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai, struct catpt_stream_runtime *stream) { struct snd_soc_component *component = dai->component; - struct snd_kcontrol *pos; + struct snd_kcontrol *pos = NULL; + struct snd_kcontrol *iter; struct catpt_dev *cdev = dev_get_drvdata(dai->dev); const char *name; int ret; @@ -354,12 +355,14 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai, return 0; } - list_for_each_entry(pos, &component->card->snd_card->controls, list) { - if (pos->private_data == component && - !strncmp(name, pos->id.name, sizeof(pos->id.name))) + list_for_each_entry(iter, &component->card->snd_card->controls, list) { + if (iter->private_data == component && + !strncmp(name, iter->id.name, sizeof(iter->id.name))) { + pos = iter; break; + } } - if (list_entry_is_head(pos, &component->card->snd_card->controls, list)) + if (!pos) return -ENOENT; if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK) From patchwork Thu Mar 31 21:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 556240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D271FC433F5 for ; Thu, 31 Mar 2022 21:54:11 +0000 (UTC) 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 D2F2918BC; Thu, 31 Mar 2022 23:53:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D2F2918BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1648763649; bh=yaWOGGxVwULFbOTEnedG4LrTQUX9qJLLkh6ctiOAYRE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mfbVFHX1rGPaEqgdrk3omFsXM3LuvBLhg7rn1jDeOir/SrlTFKrjNeGZuS051Izv7 TK+jJJWDBtwpM0PzOi7tDUCQ70JcahTybhOcjunSDClvQqWFNBU9DJcfxBP3rpJmqL NykYp13GCl7ZSrZXK5nbcrRl1bLlv8mw/kXrp5Mg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 96C93F80227; Thu, 31 Mar 2022 23:53:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 946C7F8025A; Thu, 31 Mar 2022 23:53:00 +0200 (CEST) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B7456F80100 for ; Thu, 31 Mar 2022 23:52:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B7456F80100 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JtxdpIwi" Received: by mail-ej1-x633.google.com with SMTP id i16so1971001ejk.12 for ; Thu, 31 Mar 2022 14:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0sd4Dv+ZWOb6q2yQLaNmeg8xynhdTU6RpDxBF/RZvfQ=; b=JtxdpIwivwnUVSniHaAcy7hQSSplDsADhwqzWl1+x8iL63xUZDqKO2N52/nhmLa0ie FlDJm2eXWgm+PoK9FatL2QWsapCHPQ2qOgB/6Uzg7ySRdIm7lPNprYIH1G7QpOZnBBe9 VJ3Cljp9Jn3RvFR6HWI/1Im0+8dLznGp41+gucIagQlIl6FGpRpGiPuzzBjRz9FiSohO nqe6A2Bh5o0TKxn2l/AUFkIIAouvA+HmrcVypLIzYJT5hYaOdlM93EOpBLL0j9O1s+wO GdA4uf+9U7exz1UmK+1zNG3y/yuF9DKJWgrzefFzfJJDKxcxGu9rUXaRccLHPbO29rYd wWHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0sd4Dv+ZWOb6q2yQLaNmeg8xynhdTU6RpDxBF/RZvfQ=; b=zutu4x0yihzfLK0NCm25uWXOEVac2SaAaZKORF2jRnX0/Zkq5CZ0zCaJzThC8Mg9FR 5sckUH7wOVCiBNZSkm8qE7EZW6qz57jSlXftoC8vJsA0EEpRem4lRuOGWxZP5tVMVDy0 PKfC2G76Aude6GwhaUGDr0DgeGQerfNTFfrGAMMo1qYNlOqSlgcE1rzqD/Z7kI1De+Qk JleL//owOMtA3BkxcfiJXgos0LFFkLMcy+Tg8nE0mDxH3IMLn4BQhEypeVonJughueJg dixIVmPf9mEa5iiQaeflZ3IT12IyKPENR2dWRDrIq7yidm4giVJwHUCC6WyOdD8+UBZa dbfA== X-Gm-Message-State: AOAM5326RCZ5QyFMpXN9DXUxQTypEqqmzs6EOjTXZNAtuxN/185GdJI9 jFY6abyexaMP2zTOr88v2wg= X-Google-Smtp-Source: ABdhPJwz4mdkoYMH3cHppROvh1hEcYupPDv5nUTRyVfJOCK+JnHGSyDSxVNZ5NpoYM4hYMsdq+4Nkg== X-Received: by 2002:a17:907:7284:b0:6df:9120:d935 with SMTP id dt4-20020a170907728400b006df9120d935mr6837306ejc.276.1648763576045; Thu, 31 Mar 2022 14:52:56 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id g20-20020aa7c594000000b004194b07bbfasm299980edq.10.2022.03.31.14.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:52:55 -0700 (PDT) From: Jakob Koschel To: Codrin Ciubotariu Subject: [PATCH 2/3] ASoC: sprd: remove check of list iterator against head past the loop body Date: Thu, 31 Mar 2022 23:50:02 +0200 Message-Id: <20220331215003.882143-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331215003.882143-1-jakobkoschel@gmail.com> References: <20220331215003.882143-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Cezary Rojewski , Jie Yang , Alexandre Belloni , Takashi Iwai , Liam Girdwood , Cristiano Giuffrida , Chunyan Zhang , Pierre-Louis Bossart , "Bos, H.J." , Yang Yingliang , Orson Zhai , Arnd Bergmann , Nicolas Ferre , Brian Johannesmeyer , Mark Brown , Jakob Koschel , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Baolin Wang , Claudiu Beznea , Mike Rapoport 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" When list_for_each_entry() completes the iteration over the whole list without breaking the loop, the iterator value will be a bogus pointer computed based on the head element. While it is safe to use the pointer to determine if it was computed based on the head element, either with list_entry_is_head() or &pos->member == head, using the iterator variable after the loop should be avoided. In preparation to limiting the scope of a list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- sound/soc/sprd/sprd-mcdt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sound/soc/sprd/sprd-mcdt.c b/sound/soc/sprd/sprd-mcdt.c index f6a55fa60c1b..6e27789a0df5 100644 --- a/sound/soc/sprd/sprd-mcdt.c +++ b/sound/soc/sprd/sprd-mcdt.c @@ -866,20 +866,19 @@ EXPORT_SYMBOL_GPL(sprd_mcdt_chan_dma_disable); struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel, enum sprd_mcdt_channel_type type) { - struct sprd_mcdt_chan *temp; + struct sprd_mcdt_chan *temp = NULL; + struct sprd_mcdt_chan *iter; mutex_lock(&sprd_mcdt_list_mutex); - list_for_each_entry(temp, &sprd_mcdt_chan_list, list) { - if (temp->type == type && temp->id == channel) { - list_del_init(&temp->list); + list_for_each_entry(iter, &sprd_mcdt_chan_list, list) { + if (iter->type == type && iter->id == channel) { + list_del_init(&iter->list); + temp = iter; break; } } - if (list_entry_is_head(temp, &sprd_mcdt_chan_list, list)) - temp = NULL; - mutex_unlock(&sprd_mcdt_list_mutex); return temp; From patchwork Thu Mar 31 21:50:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 555289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E0E2BC433FE for ; Thu, 31 Mar 2022 21:54:31 +0000 (UTC) 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 2C9F118DE; Thu, 31 Mar 2022 23:53:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2C9F118DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1648763670; bh=ifpWWypXortg/rGDlOym9wXGA7cugLMS1PqYp1hkuN0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pSGZKIP/wrBAjjIFtaOebmCF66TrfdFWxyHRa1gObe5qZs0F7Qy8djvrWsR6bDX7G V30WKyBy7YgGlWPTWZnImY/g7lD2aQyxklta03E2ZNFzR0shSzkP9MJDSNaiKOpOcV f02VVZV5mTR9EVjUIG3NJn2pkDhITLBzokScscB8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3280DF804BB; Thu, 31 Mar 2022 23:53:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2EC6CF804AE; Thu, 31 Mar 2022 23:53:02 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3D374F800E4 for ; Thu, 31 Mar 2022 23:52:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3D374F800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VQSaHJzJ" Received: by mail-ej1-x630.google.com with SMTP id j15so2003719eje.9 for ; Thu, 31 Mar 2022 14:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QOImAANTWLBikn8WE3acPmaj6Gy0UFu59bmhhFGIeCA=; b=VQSaHJzJLRFaxfS/H8mgdqxOLx5qp1cgKAzL60yVLDlMeAt8VGhJ9dkvSo8sse5peb boPtfzWnd11zFz27+iSxjTF4FB3YXcvxCT+y5FxIQXjsDIGZGlrAhjAUt9Gojhs/ydoV iRq25wsDAnQkMPcHv0/3gqrPQJqkQqnelapWUf1mTwoNfW/NUCQK1omIjnmbWosXVlbC h5SpKhE16NeouY/7uihnCR6OXqqIZ6MiXayAqcOpsHk8L7jbpyZ/itHHQNd+sB4jvelb 5E3hF9MNJIokJCh19DtkusmD9+MQFxQTeDbp1vVfR/7mDfIN14lven09Sut3cK8Ri4Xm 00IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QOImAANTWLBikn8WE3acPmaj6Gy0UFu59bmhhFGIeCA=; b=B4cZBEDh+gtv9jOVB3sAgivQsLNGmh7Xm1gfYsNpWTW5eOrVdj2MoWmyGT6CCfCSu/ VuPEG/evQcGuIudYeR0/3iEJ/6y2HAMNLYR8EXWa7HAv0jtgmlFa9ljs43HOVd/GPG/J +CDIRpt3hmaZRrqoPitN3KVAE9OsGWrnWSc+LvuC/qfSzvrliZu57c+64kJbMozAbVMr qckRU9fd/X1/no4xTTOPMF2lA6y6i9YK7r4UV9FRdmIoOculKQ6QhZPTH9XQVl/vbuzi U3PJ4K7HxhkgoSZeGZqh1QR4HLNO0YXuZoLpvOsspXy2PxbgsnjOqhcmkOPKnZat/VNl fjyA== X-Gm-Message-State: AOAM531wNb9lwlO7IrPJeI8hW/Nduj166e69oovh+0iDouoSWe1ehU/z BUnrE1SbMhswKPA9TaLD0Xs= X-Google-Smtp-Source: ABdhPJwhW6AYtGNMAVFbxpGjx9UHVrI4ApY9BLlL1tGNDzt2uyxR6JIV8D6VbtshApQXftpkkWYqOQ== X-Received: by 2002:a17:906:32cf:b0:6d5:83bc:e962 with SMTP id k15-20020a17090632cf00b006d583bce962mr6882166ejk.108.1648763577157; Thu, 31 Mar 2022 14:52:57 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id g20-20020aa7c594000000b004194b07bbfasm299980edq.10.2022.03.31.14.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:52:56 -0700 (PDT) From: Jakob Koschel To: Codrin Ciubotariu Subject: [PATCH 3/3] ASoC: atmel-ssc: replace usage of found with dedicated list iterator variable Date: Thu, 31 Mar 2022 23:50:03 +0200 Message-Id: <20220331215003.882143-3-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331215003.882143-1-jakobkoschel@gmail.com> References: <20220331215003.882143-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Cezary Rojewski , Jie Yang , Alexandre Belloni , Takashi Iwai , Liam Girdwood , Cristiano Giuffrida , Chunyan Zhang , Pierre-Louis Bossart , "Bos, H.J." , Yang Yingliang , Orson Zhai , Arnd Bergmann , Nicolas Ferre , Brian Johannesmeyer , Mark Brown , Jakob Koschel , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Baolin Wang , Claudiu Beznea , Mike Rapoport 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" To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Reviewed-by: Codrin Ciubotariu --- drivers/misc/atmel-ssc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index d6cd5537126c..343e25555fbb 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -25,25 +25,24 @@ static LIST_HEAD(ssc_list); struct ssc_device *ssc_request(unsigned int ssc_num) { - int ssc_valid = 0; - struct ssc_device *ssc; + struct ssc_device *ssc = NULL, *iter; mutex_lock(&user_lock); - list_for_each_entry(ssc, &ssc_list, list) { - if (ssc->pdev->dev.of_node) { - if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc") + list_for_each_entry(iter, &ssc_list, list) { + if (iter->pdev->dev.of_node) { + if (of_alias_get_id(iter->pdev->dev.of_node, "ssc") == ssc_num) { - ssc->pdev->id = ssc_num; - ssc_valid = 1; + iter->pdev->id = ssc_num; + ssc = iter; break; } - } else if (ssc->pdev->id == ssc_num) { - ssc_valid = 1; + } else if (iter->pdev->id == ssc_num) { + ssc = iter; break; } } - if (!ssc_valid) { + if (!ssc) { mutex_unlock(&user_lock); pr_err("ssc: ssc%d platform device is missing\n", ssc_num); return ERR_PTR(-ENODEV);