msm: vidc: Validate buffer size before mapping
Validate the buffer size returned from api ion_share_dma_buf()
with the actual buffer size before mapping the buffer using
api msm_dma_map_sg_attrs() to resolve video usecases failures.
CRs-Fixed: 2119739
Change-Id: I2427cccfbb5d6f0458e425342a81fa531df9ed76
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
diff --git a/drivers/media/platform/msm/vidc/msm_smem.c b/drivers/media/platform/msm/vidc/msm_smem.c
index 9b23376..3cfb94a 100644
--- a/drivers/media/platform/msm/vidc/msm_smem.c
+++ b/drivers/media/platform/msm/vidc/msm_smem.c
@@ -80,6 +80,8 @@
dprintk(VIDC_ERR,
"Size mismatch! Dmabuf size: %zu Expected Size: %lu",
buf->size, *buffer_size);
+ msm_vidc_res_handle_fatal_hw_error(smem_client->res,
+ true);
goto mem_buf_size_mismatch;
}
/* Prepare a dma buf for dma on the given device */
@@ -327,6 +329,7 @@
if (ion_flags & ION_FLAG_SECURE)
smem->flags |= SMEM_SECURE;
+ buffer_size = smem->size;
rc = msm_ion_get_device_address(inst->mem_client, ion_handle,
align, &iova, &buffer_size, smem->flags,
smem->buffer_type, &smem->mapping_info);