]> git.baikalelectronics.ru Git - kernel.git/commitdiff
swiotlb: fail map correctly with failed io_tlb_default_mem
authorRobin Murphy <robin.murphy@arm.com>
Tue, 12 Jul 2022 06:46:45 +0000 (08:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:07 +0000 (14:24 +0200)
[ Upstream commit 3acd4cc7d58ea9ab80c744ffca5f6d53fb01fc48 ]

In the failure case of trying to use a buffer which we'd previously
failed to allocate, the "!mem" condition is no longer sufficient since
io_tlb_default_mem became static and assigned by default. Update the
condition to work as intended per the rest of that conversion.

Fixes: b0688e84e0ce ("swiotlb: Convert io_default_tlb_mem to static allocation")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/dma/swiotlb.c

index 2ee5419649ed73847651f31fa4ce399d50bafcd5..e62fb7a4da694663a253e5a23b750a08b84ca435 100644 (file)
@@ -551,7 +551,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
        int index;
        phys_addr_t tlb_addr;
 
-       if (!mem)
+       if (!mem || !mem->nslabs)
                panic("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer");
 
        if (mem_encrypt_active())