Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4025339imw; Thu, 7 Jul 2022 11:22:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uw/97+bA8TM2rkRxRD9liE+Jjpi/rEOn7FT+7uPKk2tFlf7AZN4keNVluw83zlU25RjK2X X-Received: by 2002:a63:1843:0:b0:412:6ea5:ac5c with SMTP id 3-20020a631843000000b004126ea5ac5cmr14293266pgy.366.1657218150485; Thu, 07 Jul 2022 11:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657218150; cv=none; d=google.com; s=arc-20160816; b=GdgQhzNTfCYwKseh4nMz8skv5QSxg/MqPwzpoAGtoCo/kJ7oiOIRX9t/angRqjm9u5 OR08LnJFGHJO4IQ6jiDSdycg0YjN4MZ9jETaxW6Rotbwn3pUUZ6qM/1Rq1mSlOfM2xzv a4MJKgckLNnTKj74OGNE21DeD2dkAZhd8YS1vXxJ8v7add2nQXkQHcRPTJpE+5ggJkhC Ge3Fr0jPTdUOtSK2R21f/Oot+LVfdgscLk6tUv5wsqnte5hsbPcDXPmlNvbLucT/8gjl a8ijTtzdW5GSLRf6//pFMC7kyY3GEt1WzLh/WGXhSN4uOeuG9KN6Ht+2txOQw0ikHwH5 BDIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=709lizpJxneFGzEXofApEOZOyMMW1Q4gDI4hwvBQ6s4=; b=EdBVl3i5bhzvzfebwdbgUy1eqvG8QM0bRLDpq0dqkgoXJSiMjmuKvuDgkRDf4RqA+D RRUlfu+PcxdbmZ+6IRYyreOw6ROSSX1iQD1trpDTcBjYBBbAShWCMoZjkFBWS7IZrIb6 muVZ38D5xWm3Ei2UlLakzMX9JEr/wHrBa3D2+9PKNKAHJ83G5BTBew26I4CoaacocRnS WOMN+fypGhxtfQV2IvSP1VZQZk+jhVucWTsE33u/J/wEueWqnTj2eE06pQdHaCFlCbh0 t5EZAdMnEIUhyOkqhMAjJF4chYLc2Du2Zx4vnb4+hrXY6TaawkhMCyffDhgckTWdOZKF YKUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IyM0uJt0; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a17090a430800b001efabd2e96bsi4449135pjg.73.2022.07.07.11.22.18; Thu, 07 Jul 2022 11:22:30 -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=@linuxfoundation.org header.s=korg header.b=IyM0uJt0; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235947AbiGGRx3 (ORCPT + 99 others); Thu, 7 Jul 2022 13:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234968AbiGGRx2 (ORCPT ); Thu, 7 Jul 2022 13:53:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5E7101D for ; Thu, 7 Jul 2022 10:53:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 72963CE2592 for ; Thu, 7 Jul 2022 17:53:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 422F8C3411E; Thu, 7 Jul 2022 17:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657216403; bh=WFHud34Fu15V1qg6NP5QKzYr44hQraLgeUB+VU3GBO4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IyM0uJt0VKndoK5Hlj1hhDDQxeYGRK67KQS4rKrM4qIqs5p4Wg1kc2BJ1fBCl5U01 tm7pfkZty/VkQ0B3ZIqR0mFeSp4gpHf5mf5gSZ0wARUX87wXbg8J2fHOOzh9NR0mxc wbEmavR0wcV1kwhrzF8TYaX8lR5BcKO+jn6bIsKM= Date: Thu, 7 Jul 2022 19:53:20 +0200 From: Greg Kroah-Hartman To: Karthik Alapati Cc: Johan Hovold , Alex Elder , Shuah Khan , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: greybus: don't use index pointer after iter Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Thu, Jul 07, 2022 at 03:59:54PM +0530, Karthik Alapati wrote: > There are some usages of index pointer of list(w) which may not point to > the right entry when the required entry is not found and the list traversal > completes with index pointer pointing to the last entry. So, use w_found > flag to track the case where the entry is found. > > Currently, When the condition (w->dapm != dapm) is true the loop continues > and when it is not then it compares the name strings and breaks out of the > loop if they match with w pointing to the right entry and it also breaks > out of loop if they didn't match by additionally setting w to NULL. But > what if the condition (w->dapm != dapm) is never false and the list > traversal completes with w pointing to last entry then usage of it after > the iter may not be correct. And there is no way to know whether the entry > is found. So, if we introduce w_found to track when the entry is found > then we can account for the case where the entry is not actually found and > the list traversal completes. > > Fixes coccinelle error: > drivers/staging/greybus/audio_helper.c:135:7-8: ERROR: > invalid reference to the index variable of the iterator on line 127 > > Signed-off-by: Karthik Alapati Also, always at the very least, test-build your patches to ensure that they pass that step. This patch fails to build :( greg k-h