Skip to content

Commit 7a089c5

Browse files
jgunthorpejoergroedel
authored andcommitted
iommupt: Return ERR_PTR from _table_alloc()
syzkaller noticed that with fault injection a failure inside iommu_alloc_pages_node_sz() oops's in PT_FEAT_DMA_INCOHERENT because it goes on to make NULL incoherent. Closer inspection shows the return value has become confused, the alloc routines on the iommupt side expect ERR_PTR while iommu_alloc_pages_node_sz() returns NULL. Error out early to fix both issues. Fixes: aefd967 ("iommupt: Use the incoherent start/stop functions for PT_FEAT_DMA_INCOHERENT") Fixes: dcd6a01 ("iommupt: Add map_pages op") Fixes: cdb39d9 ("iommupt: Add the basic structure of the iommu implementation") Reported-by: syzbot+e06bb7478e687f235ad7@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/693a39de.050a0220.4004e.02ce.GAE@google.com/ Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent 8f0b4cc commit 7a089c5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/iommu/generic_pt/iommu_pt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ static inline struct pt_table_p *_table_alloc(struct pt_common *common,
372372

373373
table_mem = iommu_alloc_pages_node_sz(iommu_table->nid, gfp,
374374
log2_to_int(lg2sz));
375+
if (!table_mem)
376+
return ERR_PTR(-ENOMEM);
377+
375378
if (pt_feature(common, PT_FEAT_DMA_INCOHERENT) &&
376379
mode == ALLOC_NORMAL) {
377380
int ret = iommu_pages_start_incoherent(

0 commit comments

Comments
 (0)