From: Joerg Roedel <joro@8bytes.org>
To: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Cc: agross@kernel.org, bjorn.andersson@linaro.org, will@kernel.org,
sricharan@codeaurora.org, linux-arm-msm@vger.kernel.org,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] iommu: fix an incorrect NULL check on list iterator
Date: Wed, 4 May 2022 10:49:36 +0200 [thread overview]
Message-ID: <YnI+IPP0VIftWwPA@8bytes.org> (raw)
In-Reply-To: <20220501132823.12714-1-xiam0nd.tong@gmail.com>
On Sun, May 01, 2022 at 09:28:23PM +0800, Xiaomeng Tong wrote:
> The bug is here:
> if (!iommu || iommu->dev->of_node != spec->np) {
>
> The list iterator value 'iommu' 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 fact,
> it will point to a invalid structure object containing HEAD).
>
> To fix the bug, use a new value 'iter' as the list iterator, while use
> the old value 'iommu' as a dedicated variable to point to the found one,
> and remove the unneeded check for 'iommu->dev->of_node != spec->np'
> outside the loop.
>
> Cc: stable@vger.kernel.org
> Fixes: f78ebca8ff3d6 ("iommu/msm: Add support for generic master bindings")
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
> ---
> changes since v1:
> - add a new iter variable (suggested by Joerg Roedel)
This is now applied. I had to manually apply it because the patch was
malformed at line 36 and git-am complained.
Regards,
Joerg
next prev parent reply other threads:[~2022-05-04 8:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 13:28 [PATCH v2] iommu: fix an incorrect NULL check on list iterator Xiaomeng Tong
2022-05-04 8:49 ` Joerg Roedel [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-05-01 13:12 Xiaomeng Tong
2022-05-02 9:13 ` kernel test robot
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=YnI+IPP0VIftWwPA@8bytes.org \
--to=joro@8bytes.org \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sricharan@codeaurora.org \
--cc=stable@vger.kernel.org \
--cc=will@kernel.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