Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp568437iof; Mon, 6 Jun 2022 08:39:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHLXsciYTBpHvZaRiTupDpWnc+IuvbcMtH3EsFfqQcHbmdqcjjWHQ2izLeOUwff3U7B74E X-Received: by 2002:a63:3143:0:b0:3fc:6078:7e0f with SMTP id x64-20020a633143000000b003fc60787e0fmr21493037pgx.272.1654529947557; Mon, 06 Jun 2022 08:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654529947; cv=none; d=google.com; s=arc-20160816; b=axKaqOYWxJQpwKN2d1IOEhnyMXaBNWNKp7G51VEH1OqySOG+Mh4xNHbiqZn5PyKnrq DUKzzJnPX1ttgb2TDj9ERNWmqsKy/5sAuS7OMnuoaGPrstsqMutACOiV3wdYznTR7dpK RmGo3MOq7WwrTBQIe3fOeqGGgI6iNBLeunimazf2sSgyJ3laZlTqH4Stt+d8LE7VE2Wf RsLHSRJeIU5nNo4adnZqGcInilYd7r5U+dNrNLYJY08Ub9r8RqyeOBsBTjTKCAinBXXH 9FYPOg0hTwBGhz1kWQn8fOsRGNBv9ot+IprEOKGNERmb1hPBOiJKhvnXA1VaOXCJsob8 52Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=q+Uwlf6qgJvF453WbwLN1jaXprVYO3wmuZLS2RkkxFs=; b=cl87f3DB0lzZ5zjFuGL/qCunEjZl4Q8Ul4vXQm7e4mHCiQ4CTebW8ICQF9Nmq0Zefk qBwpb3o1F+PIZU35l5knJMotW7RoCvD91xumWi1Lg62Sd2YHD1wlHVDi24CGZxdb1EcR WyiwSmZcD2wATpdpVVRIT7KQcC08dcEAXmQEgUgW4KnfOYP/Fo4wbr/eBsrkvAeWNShs C/EAH2hHU+5qGtQn/szVtyTK8jkv1gtxoR6yV3wE+/Mmk/M5tG0J9YHayDGAuheX1A7P FFsy9xxEDXq4lhwyQYhaKb6fBkhCPLEyp9vBx8W7KXb/OrHJFU+rEiTxY8xyLO1mPF6A x0iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m09w9gwj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c12-20020a655a8c000000b003fbbddcde14si20163970pgt.492.2022.06.06.08.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m09w9gwj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A13391C8673; Mon, 6 Jun 2022 08:23:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240469AbiFFPWw (ORCPT + 99 others); Mon, 6 Jun 2022 11:22:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240471AbiFFPWv (ORCPT ); Mon, 6 Jun 2022 11:22:51 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00BBA35840; Mon, 6 Jun 2022 08:22:49 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id n10so29649496ejk.5; Mon, 06 Jun 2022 08:22:49 -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=q+Uwlf6qgJvF453WbwLN1jaXprVYO3wmuZLS2RkkxFs=; b=m09w9gwjIR2RAinzDyK8VruLeAVFJvHbrpa+jH7oL4BHaYqSW018C8VDZ5FfT4vyLg kNefBfLJHsDLZlV8RkJKC8ykSn5cgqkyB6k4jQdfBwSycSwz2Y4276a5v4F77KXSferg ZsKhu1CptfVOlueQ7oisLW6pMvU18Zv1B3k7IZq8sAB2opU8HQ1H2/L2XhGAvkO1NjTC mSVFBgdgRwsaDa2j/z3wTMl7LluZzvd7rYgBGxwur8G+FAr0zglFNsEyZlsKhYcP0EWW VJlrkvanXxE7DYNxjSJLAFFpi170XqtRM3xZi4myMc9TxZ/3uTlRHveq0na6un/jV+D5 PavA== 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=q+Uwlf6qgJvF453WbwLN1jaXprVYO3wmuZLS2RkkxFs=; b=a3C6JCTYfSF/teONzFUt1fgnGkPmaDP3CB3E78mNAzZJVaQJeUiFkq8nOJDT9U8zj3 PTG9onKPwNMtO33logC5ylrnVsKy0Wk32ljvWoh9ahHCpheiFh2/oDONDaAybHYXYh6W DXjDFmcfPJD1p7/Kz1gL64ptQWpB683RW5BepYd0hmRHzij0r1PMwHG7lOlkI3AT79ED rK9SZLRcJDTWz/R0b6jbyZXoE/uTh7ySa0yrk0V9UEtTiOfjyBKkvXVo8uvuPogidNPY jwbSNyuh9vAoVEUK23mdqSRZRq9zg7wfCOoIIgzWphHCdD3Icgmhpcl30+2mR55BqHiL hsKw== X-Gm-Message-State: AOAM532wHiYGNMuu5pnnl6zc6ZYyV7LzohwNAAFFMzwvhuEFdLGPOwBW 953bSXSdYPY2oYh33vI+YRA= X-Received: by 2002:a17:907:1c87:b0:6f0:29ea:cc01 with SMTP id nb7-20020a1709071c8700b006f029eacc01mr22180895ejc.671.1654528968351; Mon, 06 Jun 2022 08:22:48 -0700 (PDT) Received: from localhost.localdomain ([138.199.7.159]) by smtp.gmail.com with ESMTPSA id b3-20020a170906660300b00711aed17047sm2348128ejp.28.2022.06.06.08.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:22:47 -0700 (PDT) From: Yassine Oudjana X-Google-Original-From: Yassine Oudjana To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Yassine Oudjana , Yassine Oudjana , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one Date: Mon, 6 Jun 2022 19:22:26 +0400 Message-Id: <20220606152226.149164-1-y.oudjana@protonmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yassine Oudjana Currently in slim_rx_mux_put, an RX channel gets added to a new list even if it is already in one. This can mess up links and make either it, the new list head, or both, get linked to the wrong entries. This can cause an entry to link to itself which in turn ends up making list_for_each_entry in other functions loop infinitely. To avoid issues, always remove the RX channel from any list it's in before adding it to a new list. Signed-off-by: Yassine Oudjana --- sound/soc/codecs/wcd9335.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 617a36a89dfe..597420679505 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -1289,9 +1289,12 @@ static int slim_rx_mux_put(struct snd_kcontrol *kc, wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; + /* Remove channel from any list it's in before adding it to a new one */ + list_del_init(&wcd->rx_chs[port_id].list); + switch (wcd->rx_port_value[port_id]) { case 0: - list_del_init(&wcd->rx_chs[port_id].list); + /* Channel already removed from lists. Nothing to do here */ break; case 1: list_add_tail(&wcd->rx_chs[port_id].list, -- 2.36.1