Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1215969pxb; Wed, 6 Apr 2022 11:33:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy822iXCsZU65kkMT79L8jPxvi4M6sG86vfhniGbFxxCrvc0Uk7XYJoHoYsLwBv0Wz9fLCm X-Received: by 2002:a17:903:2283:b0:156:3e9b:282b with SMTP id b3-20020a170903228300b001563e9b282bmr10118529plh.94.1649270019811; Wed, 06 Apr 2022 11:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649270019; cv=none; d=google.com; s=arc-20160816; b=TGNzxHXP4vv6G+r+DxhOYb4eiCPK5pcAHri8y/RLIb4TyOSVjItj8Hx2F/MqyAkNC9 taP91YWCLu5EnGImZvuRaUWy6xx6OdoAD/Tmn6Orz1MLH1XjnT68vALAmBmmgOShWWFd K3Np4xRDMXZ2dNvDv8mD+LyhyWWPyG1nsw/u0GjIv9Tl+9EUIijHkxyhUTzITABeTvBV AUC/jMDeHgv7qNZ+J6IxXkKiibd733Ai+zbI1NecK/1uPGs1Mc8R5QoZNlbZa5lbGRXD 1Ksc8u4+Ze3z2ZaJ1cLZ3lE0etS/36gHA59vCbnHuG9VzZuvqU4GUelSOiLj6nu6GTe+ 5/1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zCm35dqJeIsDGwuyLVEnPyr0Q2EEi3+4jjs5g8wcZjU=; b=DEThGqIdxiW6vQwM55Jj/Gj6QO+qlCsDoP47emqv4HENq4r0kranm5DSuuu5NZ5VbH e7rNeQLH1TbhOW2UmXYGZN1XI4+eMxqhi/vyWaqqLLh+OPjNG3cc0pR8dzkz3RXYz6hr GzaVZ6+mnv2cYeZHItxWFTeNuMMwknwQFzr0+sLRsQtHq9EN0/etlFQa4sMh4xhibfRc Zng06Pg+ID7Vb3fcfgK4FCq+S+16soFlaAazxZw2V6MXQnSuZ3VTgfH0SrPIpXx4nFw0 4Z1hu6YAs9OaPa6EVSqLtrsamE/8pMAdwmbTxwIWmZ3zYkWU/Gd5R/MojIfwjj5i/fxS lFeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=a9yGXzAX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s24-20020a170902989800b00153b2d164b7si14852898plp.191.2022.04.06.11.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@quicinc.com header.s=qcdkim header.b=a9yGXzAX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4805BB90B; Wed, 6 Apr 2022 11:17:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240371AbiDFSTd (ORCPT + 69 others); Wed, 6 Apr 2022 14:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241268AbiDFSSc (ORCPT ); Wed, 6 Apr 2022 14:18:32 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D58D1877E5; Wed, 6 Apr 2022 10:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649264554; x=1680800554; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=zCm35dqJeIsDGwuyLVEnPyr0Q2EEi3+4jjs5g8wcZjU=; b=a9yGXzAXrrEvTK3brLkFa/vFFy1K1VLtfMW+E4W5rxFQY5cHkDARwA09 SLnp/h7nXqMMCYfGrvnzSAO2qo9s0jG/y5pSND6cJnyJzv/y8/RabKSRx Hg/FHpK//3P5Hgc2Lzj3bbg4qyetQgWOCYBPJ4RDTjdfh71eogOAX7Gvw I=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 06 Apr 2022 10:02:34 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 10:02:33 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 6 Apr 2022 10:02:33 -0700 Received: from [10.110.72.142] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 6 Apr 2022 10:02:32 -0700 Message-ID: Date: Wed, 6 Apr 2022 10:02:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2] cw1200: fix incorrect check to determine if no element is found in list Content-Language: en-US To: Kalle Valo , Xiaomeng Tong CC: , , , , , , , , References: <20220320035436.11293-1-xiam0nd.tong@gmail.com> <164924475461.19026.8095141212129340061.kvalo@kernel.org> From: Jeff Johnson In-Reply-To: <164924475461.19026.8095141212129340061.kvalo@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-wireless@vger.kernel.org On 4/6/2022 4:32 AM, Kalle Valo wrote: > Xiaomeng Tong wrote: > >> The bug is here: "} else if (item) {". >> >> The list iterator value will *always* be set and non-NULL by >> list_for_each_entry(), so it is incorrect to assume that the iterator >> value will be NULL if the list is empty or no element is found in list. >> >> Use a new value 'iter' as the list iterator, while use the old value >> 'item' as a dedicated pointer to point to the found element, which >> 1. can fix this bug, due to now 'item' is NULL only if it's not found. >> 2. do not need to change all the uses of 'item' after the loop. >> 3. can also limit the scope of the list iterator 'iter' *only inside* >> the traversal loop by simply declaring 'iter' inside the loop in the >> future, as usage of the iterator outside of the list_for_each_entry >> is considered harmful. https://lkml.org/lkml/2022/2/17/1032 >> >> Fixes: a910e4a94f692 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets") >> Signed-off-by: Xiaomeng Tong > > Can someone review this, please? > Reviewed-by: Jeff Johnson