From: Jeff Johnson <quic_jjohnson@quicinc.com>
To: Kalle Valo <kvalo@kernel.org>, Xiaomeng Tong <xiam0nd.tong@gmail.com>
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>
Subject: Re: [PATCH v2] cw1200: fix incorrect check to determine if no element is found in list
Date: Wed, 6 Apr 2022 10:02:31 -0700 [thread overview]
Message-ID: <fb02ab86-4c7f-8303-621d-349ac8c25546@quicinc.com> (raw)
In-Reply-To: <164924475461.19026.8095141212129340061.kvalo@kernel.org>
On 4/6/2022 4:32 AM, Kalle Valo wrote:
> Xiaomeng Tong <xiam0nd.tong@gmail.com> 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 <xiam0nd.tong@gmail.com>
>
> Can someone review this, please?
>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
next prev parent reply other threads:[~2022-04-06 18:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-20 3:54 Xiaomeng Tong
2022-04-06 11:32 ` Kalle Valo
2022-04-06 17:02 ` Jeff Johnson [this message]
2022-04-12 13:51 ` Kalle Valo
2022-04-13 9:21 ` Xiaomeng Tong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb02ab86-4c7f-8303-621d-349ac8c25546@quicinc.com \
--to=quic_jjohnson@quicinc.com \
--cc=davem@davemloft.net \
--cc=jakobkoschel@gmail.com \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pizza@shaftnet.org \
--cc=xiam0nd.tong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®