Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp775928pxb; Tue, 12 Apr 2022 13:08:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI1GmAjL7e78ZGgFPSGXexIsXf6T3Cv853VgCWrXOUX2nJ/s0JeHd7QliEJWUkMi4deTaR X-Received: by 2002:a17:90a:4308:b0:1cb:b996:1dc with SMTP id q8-20020a17090a430800b001cbb99601dcmr6915129pjg.224.1649794135475; Tue, 12 Apr 2022 13:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649794135; cv=none; d=google.com; s=arc-20160816; b=RWlicdsDOrhhHhyBrUv4IhR8ko5dYlS/cO3gqpkuHREeuiDstRUv9qny8bYuMiou+H l1SPoLxWUWZ1qqmeRu+Sa/CBeA7Njk4VV3bdCJU2z9A7bWyFRTvXZD7FeRgOQavQr4Cf sl/4T8IbiA0hihWiJuF3xvabbC3BEbEIlWDCVOH9qNhIQ7qUgWEWUtattXUqlPA0pfLP U4p4DB01RdTB1g3m8PZucF++LgRkXEgUBYSf2apmomBp1ec9amtwrjzS7nL6BmZ+zVIs A734h+mgRr4Hb3qGkEJP82XLUKOkK+FYXlk0uQ62IsYArpLh8pLjx7OxTXVaP0QKfRF/ rtDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=Y3u2YCNy5zhOlabnV4tIS/cm2uoX8oiaQ31+qbmRjH8=; b=N+CbwT0zjj42XaTspK/tihg7fehwA6dOL6+LwNDGkOYhgqttl7nEyGW5LthSbNY2MQ xfUx8g41cIvs2GnbivaZ2ZyJC9GZRRCeCXwaelCZPIOU8XRWO/xj8F3RNv7n/VvHvvD2 TYpws+edTMePTrfaabmQM7rjUexUIb9bfJDdyY1xxcZ24P4pJBu8J3mRulL+wEgt+PCo k0ju0gvKPjC3FXnJz7xxfbcuGTT7clEi+AQcWpjZb9TGyv+9iJwVgYdw6xyIhjzCLUhs 6V4ElBF/LrLngQrzjSFppwbaIzr/wYK8NLtX6n6l+oHZH3wThbU6HbJpLVCGiFNZJq8b mC2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NXIhiHyK; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h4-20020a17090a648400b001cb9ba78d1fsi6775970pjj.19.2022.04.12.13.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:08:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NXIhiHyK; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82B5E70F71; Tue, 12 Apr 2022 12:57:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356284AbiDLNxo (ORCPT + 70 others); Tue, 12 Apr 2022 09:53:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239232AbiDLNxn (ORCPT ); Tue, 12 Apr 2022 09:53:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759A155BEE; Tue, 12 Apr 2022 06:51:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1076161AE3; Tue, 12 Apr 2022 13:51:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 220A3C385A5; Tue, 12 Apr 2022 13:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649771484; bh=1IVfo5Yk3XxTLv9hzGny7mpq5l2FdcstMt/R+wNLyuE=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=NXIhiHyK5WCGGNiGBzTM7XGQGQZ2WIBhvMOJsI+i5rf1/ifqSOQYeMAbV0QqH31nP UnxOMeGZ37DpdN71iDEScRhAKKsnQBY37J0MULfHnVKVG0nUr23NxnOzV26AHLRGqU 0afi+Ph68N2/3FuwfUttrCjKYhaDIOvBHfP2FMtc2TJPV/FE5g76WVxCWfroCQjdlh CXdy5sSDeXjn89nz5LsXsM4JmQhRYf9Lao3CYLd+El9KlUDOVBmaXtdqijGtyaYGJu bvvvuFGwjeQF2a0Cz+7UXkmMfo1/yZp8CtpgbnE8EJMipIkNUbU1a+WQYWzBGs04dA yOhGmq0WRCZHA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH v2] cw1200: fix incorrect check to determine if no element is found in list From: Kalle Valo In-Reply-To: <20220320035436.11293-1-xiam0nd.tong@gmail.com> References: <20220320035436.11293-1-xiam0nd.tong@gmail.com> To: Xiaomeng Tong Cc: pizza@shaftnet.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, linville@tuxdriver.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jakobkoschel@gmail.com, Xiaomeng Tong User-Agent: pwcli/0.1.0-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <164977147986.6629.2901483762629864309.kvalo@kernel.org> Date: Tue, 12 Apr 2022 13:51:21 +0000 (UTC) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 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 > Reviewed-by: Jeff Johnson Failed to apply, please rebase on top of latest wireless-next. Recorded preimage for 'drivers/net/wireless/st/cw1200/queue.c' error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Applying: cw1200: fix incorrect check to determine if no element is found in list Using index info to reconstruct a base tree... M drivers/net/wireless/st/cw1200/queue.c Falling back to patching base and 3-way merge... Auto-merging drivers/net/wireless/st/cw1200/queue.c CONFLICT (content): Merge conflict in drivers/net/wireless/st/cw1200/queue.c Patch failed at 0001 cw1200: fix incorrect check to determine if no element is found in list Patch set to Changes Requested. -- https://patchwork.kernel.org/project/linux-wireless/patch/20220320035436.11293-1-xiam0nd.tong@gmail.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches