* [PATCH v2] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE
@ 2024-11-15 18:46 Kees Bakker
2025-01-02 3:11 ` Baolu Lu
0 siblings, 1 reply; 2+ messages in thread
From: Kees Bakker @ 2024-11-15 18:46 UTC (permalink / raw)
To: Baolu Lu, iommu, Tian Kevin, Joerg Roedel, Will Deacon, Robin Murphy
Cc: linux-kernel
There is a WARN_ON_ONCE to catch an unlikely situation when
domain_remove_dev_pasid can't find the `pasid`. In case it nevertheless
happens we must avoid using a NULL pointer.
Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
---
v1 -> v2: change subject to use 'iommu/vt-d:' prefix
drivers/iommu/intel/iommu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 82ee86d86a93..e933c84faf0b 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4089,13 +4089,14 @@ void domain_remove_dev_pasid(struct iommu_domain *domain,
break;
}
}
- WARN_ON_ONCE(!dev_pasid);
spin_unlock_irqrestore(&dmar_domain->lock, flags);
cache_tag_unassign_domain(dmar_domain, dev, pasid);
domain_detach_iommu(dmar_domain, iommu);
- intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
- kfree(dev_pasid);
+ if (!WARN_ON_ONCE(!dev_pasid)) {
+ intel_iommu_debugfs_remove_dev_pasid(dev_pasid);
+ kfree(dev_pasid);
+ }
}
static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
--
2.47.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE
2024-11-15 18:46 [PATCH v2] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE Kees Bakker
@ 2025-01-02 3:11 ` Baolu Lu
0 siblings, 0 replies; 2+ messages in thread
From: Baolu Lu @ 2025-01-02 3:11 UTC (permalink / raw)
To: Kees Bakker, iommu, Tian Kevin, Joerg Roedel, Will Deacon, Robin Murphy
Cc: linux-kernel
On 11/16/24 02:46, Kees Bakker wrote:
> There is a WARN_ON_ONCE to catch an unlikely situation when
> domain_remove_dev_pasid can't find the `pasid`. In case it nevertheless
> happens we must avoid using a NULL pointer.
>
> Signed-off-by: Kees Bakker<kees@ijzerbout.nl>
> ---
> v1 -> v2: change subject to use 'iommu/vt-d:' prefix
>
> drivers/iommu/intel/iommu.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
Queued for v6.14. Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-02 3:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-15 18:46 [PATCH v2] iommu/vt-d: Avoid use of NULL after WARN_ON_ONCE Kees Bakker
2025-01-02 3:11 ` Baolu Lu
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®