[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YnI+IPP0VIftWwPA@8bytes.org>
Date: Wed, 4 May 2022 10:49:36 +0200
From: Joerg Roedel <joro@...tes.org>
To: Xiaomeng Tong <xiam0nd.tong@...il.com>
Cc: agross@...nel.org, bjorn.andersson@...aro.org, will@...nel.org,
sricharan@...eaurora.org, linux-arm-msm@...r.kernel.org,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH v2] iommu: fix an incorrect NULL check on list iterator
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@...r.kernel.org
> Fixes: f78ebca8ff3d6 ("iommu/msm: Add support for generic master bindings")
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@...il.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
Powered by blists - more mailing lists