From: Robin Murphy Date: Tue, 12 Jul 2022 06:46:45 +0000 (+0200) Subject: swiotlb: fail map correctly with failed io_tlb_default_mem X-Git-Tag: baikal/mips/sdk5.9~181 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=136071cd58e06a541724661765cbf72c62c9d8a1;p=kernel.git swiotlb: fail map correctly with failed io_tlb_default_mem [ 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 Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 2ee5419649ed7..e62fb7a4da694 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -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())