[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874b493e-a669-4d54-9ba3-45cd23b075d7@linux.intel.com>
Date: Wed, 4 Sep 2024 09:07:12 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Qianqiang Liu <qianqiang.liu@....com>, dwmw2@...radead.org
Cc: baolu.lu@...ux.intel.com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iommu/vt-d: Fix 'Null pointer dereferences' issue
On 9/3/24 10:46 PM, Qianqiang Liu wrote:
> Passing null pointer "pdev" to "pci_enable_pasid", which dereferences it.
> Check the "pdev" is null or not before passing to "pci_enable_pasid".
>
> Signed-off-by: Qianqiang Liu<qianqiang.liu@....com>
> ---
> drivers/iommu/intel/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 9f6b0780f2ef..a1e54f334330 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -3935,7 +3935,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
> * So always enable PASID support on devices which have it, even if
> * we can't yet know if we're ever going to use it.
> */
> - if (info->pasid_supported &&
> + if (info->pasid_supported && pdev &&
> !pci_enable_pasid(pdev, info->pasid_supported & ~1))
> info->pasid_enabled = 1;
'info->pasid_supported=true' implies that pdev should never be NULL.
There's no need for an extra check.
Thanks,
baolu
Powered by blists - more mailing lists