From: Anand K Mistry Date: Mon, 20 Apr 2020 06:08:34 +0000 (+1000) Subject: drm/mediatek: Stop iterating dma addresses when sg_dma_len() == 0 X-Git-Tag: baikal/mips/sdk5.9~13559^2~4^2~2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=b04620518c6c594abb5e4205fbd2cdddeac7f2c8;p=kernel.git drm/mediatek: Stop iterating dma addresses when sg_dma_len() == 0 If dma_map_sg() merges pages when creating the mapping, only the first entries will have a valid sg_dma_address() and sg_dma_len(), followed by entries with sg_dma_len() == 0. Signed-off-by: Anand K Mistry Signed-off-by: Anand K Mistry Signed-off-by: Chun-Kuang Hu --- diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c index b04a3c2b111e0..f8fd8b98c30e3 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c @@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, expected = sg_dma_address(sg->sgl); for_each_sg(sg->sgl, s, sg->nents, i) { + if (!sg_dma_len(s)) + break; + if (sg_dma_address(s) != expected) { DRM_ERROR("sg_table is not contiguous"); ret = -EINVAL;