]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu: Convert unreachable() to BUG()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Thu, 27 Mar 2025 05:28:46 +0000 (22:28 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 28 Mar 2025 13:07:23 +0000 (10:07 -0300)
Bare unreachable() should be avoided as it generates undefined behavior,
e.g. falling through to the next function.  Use BUG() instead so the
error is defined.

Fixes the following warnings:

  drivers/iommu/dma-iommu.o: warning: objtool: iommu_dma_sw_msi+0x92: can't find jump dest instruction at .text+0x54d5
  vmlinux.o: warning: objtool: iommu_dma_get_msi_page() falls through to next function __iommu_dma_unmap()

Link: https://patch.msgid.link/r/0c801ae017ec078cacd39f8f0898fc7780535f85.1743053325.git.jpoimboe@kernel.org
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Closes: https://lore.kernel.org/314f8809-cd59-479b-97d7-49356bf1c8d1@infradead.org
Reported-by: Paul E. McKenney <paulmck@kernel.org>
Closes: https://lore.kernel.org/5dd1f35e-8ece-43b7-ad6d-86d02d2718f6@paulmck-laptop
Fixes: 6aa63a4ec947 ("iommu: Sort out domain user data")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/dma-iommu.c

index 2bd9f80a83fe45955cf39b3210f7199bb76d8ce6..8cc5397d7dfc1a254aba073e6e182c64ebadbb2d 100644 (file)
@@ -1762,7 +1762,7 @@ static size_t cookie_msi_granule(const struct iommu_domain *domain)
        case IOMMU_COOKIE_DMA_MSI:
                return PAGE_SIZE;
        default:
-               unreachable();
+               BUG();
        };
 }
 
@@ -1774,7 +1774,7 @@ static struct list_head *cookie_msi_pages(const struct iommu_domain *domain)
        case IOMMU_COOKIE_DMA_MSI:
                return &domain->msi_cookie->msi_page_list;
        default:
-               unreachable();
+               BUG();
        };
 }