Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1109469pxb; Wed, 6 Apr 2022 08:57:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuirGCiMhTIlGiBxivw4dX0NTu/dKU4vjLBMk+aSjH93U57L1lelDxco1DrgKudAlkCFwm X-Received: by 2002:a05:6870:210b:b0:de:6ec1:3f59 with SMTP id f11-20020a056870210b00b000de6ec13f59mr4230790oae.171.1649260656563; Wed, 06 Apr 2022 08:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260656; cv=none; d=google.com; s=arc-20160816; b=Ly3gInHsWMWQXKRf0tgcahFipRuOb5doIvJSTbql28FZAkiYFYOiGlCiGP+wRUGmen zuzbKwiey0bCKzwoxneXO5pVFL9onss7QhJxpTJZt645SlxyUkIlprNTWTKArJ8BgQsm jQYR4kxiKvPFyWq/ZgoWSATnuD4qXzb0gDPF7Oy9uvhNXSMRGsgOT1r0ugE3JJ5+B7fR WFwdtI29sMcjceu/FisLkllxzc3XWq6mRmPdiKlLjz0Agnw/C2ue3FOxy4y17rK15s4d VDn9u6oaz60iezmBmj8+qTKk8+nHQ1+fJ0kMvnN2GEf2jmvpqNVMwYth6O/JgZ/SCXWd h9cw== 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=FnmNYwYn7vuWOw1Yn919S25M4mmgztW13/t7auOxFqc=; b=j2N7QA606fye6wXB+TUoYGIhm7koej+1l+zrsSOTCCDBwEkv2Yg5UtWm8BBa9pbGat RJhVUIItUfcUWmK8dXkJmHwHO5E1oFeoeViKUB8gMsQRzgOixzIlyPNb1jxoUldAOxzf 0LlQZW9MYHEsvtMFwYb69cHqUNuBjIW1gcS5sssTayYxVYpwuKtCExd0pm1yDvu19Ysw EV9Ljysc9ewghmOrPT6UDevhX11Lr9zLpW+379m4CSokVmN4Am0PyH+J/Z03W3pSNWnm SdugVx33fRxaybZ7SPkCKjkSqBEyPwxY+h31hJmlzy4sGG/Qzqq76S97iJPmZMgs/65N OsAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sa4xdPOb; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m18-20020a056820051200b003244bc5df5bsi294241ooj.87.2022.04.06.08.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:57:36 -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=@kernel.org header.s=k20201202 header.b=Sa4xdPOb; 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=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93DA9259B4E; Wed, 6 Apr 2022 07:54:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235365AbiDFO4T (ORCPT + 69 others); Wed, 6 Apr 2022 10:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235326AbiDFO4K (ORCPT ); Wed, 6 Apr 2022 10:56:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0092A607705; Wed, 6 Apr 2022 04:32:41 -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 41CB76179A; Wed, 6 Apr 2022 11:32:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4941CC385A3; Wed, 6 Apr 2022 11:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649244760; bh=IQBcwFj9MqsdsNJ0kqmRqwox5Bmr/ngz6SEfMkZ1JJ4=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=Sa4xdPObrnpMA40mL0TTMsIa4EDjSiv9e/fDS6eSD2oeV87/LFHcESGSJSklK/66y yFb08/DutTekWoY137FmUEIYGBRUEdkcyt2WSj7sw8UwsIEs4IoXoiwwD1Hlqb+W8d eyu7iE8J1dsDC64m4rR1wJZk0ys6eDdMpCS67L3Ag3y2sHjcKwVHYLwBdgWhYkJth8 mSPBLazQCWGqMzBWA7Wq+VkkjG1uhISdV3WkXN8BCyxpt/io/4mSIrHsCYkrDpi6cy I3FOCsSsdh3f90Eel7B2M9Y+FIs1C4FCcSI8oIg3i1bE9M9/Vqk/X5ezwUdFVwrgc8 UhW2DbvYUaLfA== 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: <164924475461.19026.8095141212129340061.kvalo@kernel.org> Date: Wed, 6 Apr 2022 11:32:38 +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 Can someone review this, please? -- https://patchwork.kernel.org/project/linux-wireless/patch/20220320035436.11293-1-xiam0nd.tong@gmail.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches