Re: [PATCH] iommu/amd: Fix potential @entry null deref
From: Joerg Roedel
Date: Fri Sep 18 2020 - 04:36:24 EST
On Thu, Sep 10, 2020 at 06:16:21PM +0100, Joao Martins wrote:
> After commit 26e495f34107 ("iommu/amd: Restore IRTE.RemapEn bit after
> programming IRTE"), smatch warns:
>
> drivers/iommu/amd/iommu.c:3870 amd_iommu_deactivate_guest_mode()
> warn: variable dereferenced before check 'entry' (see line 3867)
>
> Fix this by moving the @valid assignment to after @entry has been checked
> for NULL.
>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> Fixes: 26e495f34107 ("iommu/amd: Restore IRTE.RemapEn bit after programming IRTE")
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
> ---
> drivers/iommu/amd/iommu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Applied for v5.9, thanks.