iommufd: Add iopt_area_alloc()
authorJason Gunthorpe <jgg@nvidia.com>
Mon, 30 Oct 2023 14:26:33 +0000 (11:26 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:17 +0000 (11:59 +0100)
commit1baf6c5f7c1cc96d8482b2b105cf00bfaf882ec3
tree51c4d60acfed297d592e645af04bfce3f1182f77
parentfca21e139d2118727ccff8fbbe21c25711476ea2
iommufd: Add iopt_area_alloc()

[ Upstream commit 361d744ddd61de065fbeb042aaed590d32dd92ec ]

We never initialize the two interval tree nodes, and zero fill is not the
same as RB_CLEAR_NODE. This can hide issues where we missed adding the
area to the trees. Factor out the allocation and clear the two nodes.

Fixes: 51fe6141f0f6 ("iommufd: Data structure to provide IOVA to PFN mapping")
Link: https://lore.kernel.org/r/20231030145035.GG691768@ziepe.ca
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/iommufd/io_pagetable.c
drivers/iommu/iommufd/pages.c