iommu/ipmmu-vmsa: Check for error num after setting mask
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 6 Jan 2022 02:43:02 +0000 (10:43 +0800)
committerJoerg Roedel <jroedel@suse.de>
Mon, 14 Feb 2022 12:42:02 +0000 (13:42 +0100)
Because of the possible failure of the dma_supported(), the
dma_set_mask_and_coherent() may return error num.
Therefore, it should be better to check it and return the error if
fails.

Fixes: 1c894225bf5b ("iommu/ipmmu-vmsa: IPMMU device is 40-bit bus master")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Link: https://lore.kernel.org/r/20220106024302.2574180-1-jiasheng@iscas.ac.cn
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/ipmmu-vmsa.c

index ca752bdc710f6a5f35be6bb2d1b472197767ce92..61bd9a3004edeb7e7c071247edd833b2c9fb9f42 100644 (file)
@@ -1006,7 +1006,9 @@ static int ipmmu_probe(struct platform_device *pdev)
        bitmap_zero(mmu->ctx, IPMMU_CTX_MAX);
        mmu->features = of_device_get_match_data(&pdev->dev);
        memset(mmu->utlb_ctx, IPMMU_CTX_INVALID, mmu->features->num_utlbs);
-       dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
+       ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
+       if (ret)
+               return ret;
 
        /* Map I/O memory and request IRQ. */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);