Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1735076pxp; Mon, 21 Mar 2022 04:02:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweu7T7LKa6GoAUHyLqYBFD0jGIy+22OCFx8rFoT2Ny8oFJnRdBjqMwiefjuBB1vKHt5dSD X-Received: by 2002:a17:906:facf:b0:6cd:ed0e:ed7 with SMTP id lu15-20020a170906facf00b006cded0e0ed7mr19678098ejb.376.1647860546754; Mon, 21 Mar 2022 04:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647860546; cv=none; d=google.com; s=arc-20160816; b=S4BEA0D7z5Kxa5Qarg26Gfnz3tTDGCIOpYuO7UpoX2LZWEH+NfM9NzTUl/84A+cib6 vD5+moD2xw120elKiuRPjO4nbNUC+iDDNNet5hwOVvRWh7RI4nbBz7a/pS5gWFvtbGC3 1IMhfkcJHSwZ4bAmcGEJuuM2kgBPdXgQrF44o3w4zHwgRcu3oZdzrC8IGBGLuyOYNB6C 7PjNZXvlhAVmUhtkX6M7yf+YG8UKuXRfUDdbcKlYRWEZdfYAYDR76Zkndvv8VObFdY5P 4Sp5p1B5Fvi+O2Y9t5tgWdktOs71Ghjzk81apMDPCAKCtuvZub42BarAkpjlSxgt0I2j y60Q== 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=vHLMgXqZPwAjL27Id0sSqj94GzZmSc3lr7K5901Tgpk=; b=I8w4Zf0ZxskeJvx/UfXGVoAkcD3COAkHma3UtEZw8utCyFG5yBiiz1NYfTTecHZv3m J/6zlyRakFWqwX2bAZNmWT69B/jxMnsl/h8BADAGbKYtktXI+1lpGau65NaJpq5SrSJT HLhaYQio9ncbfKbz9kUsfy8H+hDARaFlN1t+6Yjl8kACAylOFyHe9eD3DOjDGhtGCGT0 NKaQdqhNA0BWF9EIAyu688UPyXaZT0x8TPN2LAOcdSZFJLJ6Vs5N3YTLERgOQuhgw55x 1QAoAbkp9xTTl36TVZfmlqR6GZ+Z8phWpWcypRlDsE6dO3O4rwSkoQnix0bSyW5d/00Q C9Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ZNtk/pp6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a056402236e00b00418c2b5be6bsi10040011eda.333.2022.03.21.04.01.53; Mon, 21 Mar 2022 04:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ZNtk/pp6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244111AbiCSUWx (ORCPT + 99 others); Sat, 19 Mar 2022 16:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240604AbiCSUWw (ORCPT ); Sat, 19 Mar 2022 16:22:52 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB30939B83 for ; Sat, 19 Mar 2022 13:21:30 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a8so22978200ejc.8 for ; Sat, 19 Mar 2022 13:21:30 -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=vHLMgXqZPwAjL27Id0sSqj94GzZmSc3lr7K5901Tgpk=; b=ZNtk/pp6yjLOiEaL/Kugxtk0VwmKSKQnMp/QX0Odlg3DSks4r6MCEHTB2EMZVVWn/v LmxJMZ1Rq6QEspYvEcZte27/pKeHa0zXORDmOttJad8LaM34/xYNQUB/4xPmTAPahkKz Tr6BWdiDNZykYDrMsAmIM/C/3lNOu4YYqZc6aY5xhrUb0aKzOp/M0+wrEnFcV+9qObg5 yR/Pk1uYxQdc4ZEQwdgfYLYky5w4VzBG61xmOuAq1TAwHXNuvuLBhN7UrECZdY0zce+2 wsVM+mYksjFjU2YnPResFSJ2/n0h3bXnuLxDhOsNabpEjrcDwuG9q5SpLpi/VGfM03pu zMRw== 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=vHLMgXqZPwAjL27Id0sSqj94GzZmSc3lr7K5901Tgpk=; b=WOza1Z2kNBJc6rCuK3kVzET32sDp0EwxRGBb30b+e34iU4/rMaYKc05wne4x88ptBg yMr0lzCr1sx3nGYfvhzdDIMbGFjOHtsavBrz4qAUbvMimwLDjIlBKNd5xb3IWEc0r7Fv +9Uw11yj/Guvjwcqf6RWrxQyHCHo9VBkjT4SC/xbORDM7X7+lebeS7fYlT7cbkiMAxma 1DU1WFSc9owqnQXbxE4CmiKKSnwUray9tjauxvdG0ux+eyjZ/ECPXxpCd7zzRPmRpzxz 510hiPOv139vIywPSr30RtHsOHWwNpz9Hw/EyLk6tO3ag9GUSdQjbulkGBAnGTOD5muH tMAQ== X-Gm-Message-State: AOAM532DDCHZjGLzCUgZ4dge4zRrlpb2jxmH6HBBUjEHzNUgMjjM2Dhk xcs4ytbmikimN9p6vnMS2xA= X-Received: by 2002:a17:906:7c93:b0:6cd:341a:a1d5 with SMTP id w19-20020a1709067c9300b006cd341aa1d5mr13999454ejo.698.1647721289256; Sat, 19 Mar 2022 13:21:29 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id rv11-20020a17090710cb00b006d5c0cd5e0dsm5103628ejb.82.2022.03.19.13.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Mar 2022 13:21:28 -0700 (PDT) From: Jakob Koschel To: Vaibhav Agarwal Cc: Jakob Koschel , linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, Mark Greer , Johan Hovold , Alex Elder , Greg Kroah-Hartman , Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH] staging: greybus: codecs: fix type confusion with dedicated list iterator variable Date: Sat, 19 Mar 2022 21:20:58 +0100 Message-Id: <20220319202058.2518847-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 If the list does not exit early then data == NULL and 'module' does not point to a valid list element. Using 'module' in such a case is not valid and was therefore removed. In preparation to limit the scope of the list iterator to the list traversal loop, use a dedicated pointer pointing to the found element [1]. Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/ Signed-off-by: Jakob Koschel --- drivers/staging/greybus/audio_codec.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index b589cf6b1d03..0f50d1e51e2c 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -497,7 +497,7 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int ret; - struct gbaudio_module_info *module; + struct gbaudio_module_info *module = NULL, *iter; struct gbaudio_data_connection *data; struct gb_bundle *bundle; struct gbaudio_codec_info *codec = dev_get_drvdata(dai->dev); @@ -511,11 +511,13 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, return -ENODEV; } - list_for_each_entry(module, &codec->module_list, list) { + list_for_each_entry(iter, &codec->module_list, list) { /* find the dai */ - data = find_data(module, dai->id); - if (data) + data = find_data(iter, dai->id); + if (data) { + module = iter; break; + } } if (!data) { dev_err(dai->dev, "DATA connection missing\n"); @@ -563,7 +565,7 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { int ret; struct gbaudio_data_connection *data; - struct gbaudio_module_info *module; + struct gbaudio_module_info *module = NULL, *iter; struct gb_bundle *bundle; struct gbaudio_codec_info *codec = dev_get_drvdata(dai->dev); struct gbaudio_stream_params *params; @@ -592,15 +594,17 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream) return ret; } - list_for_each_entry(module, &codec->module_list, list) { + list_for_each_entry(iter, &codec->module_list, list) { /* find the dai */ - data = find_data(module, dai->id); - if (data) + data = find_data(iter, dai->id); + if (data) { + module = iter; break; + } } if (!data) { - dev_err(dai->dev, "%s:%s DATA connection missing\n", - dai->name, module->name); + dev_err(dai->dev, "%s DATA connection missing\n", + dai->name); mutex_unlock(&codec->lock); return -ENODEV; } base-commit: 34e047aa16c0123bbae8e2f6df33e5ecc1f56601 -- 2.25.1