From dc9b7b572c02e0ba32fcf1cf86927231931321ee Mon Sep 17 00:00:00 2001 From: Ketan Patil Date: Sat, 1 Jun 2024 01:32:40 -0700 Subject: [PATCH] video: tegra: nvmap: Correct the data type When granule_size of type u32 and size is more than 4GB (i.e. value having more than 32 bits), then ALIGN_GRANULE_SIZE would return incorrect value due to ~(GRANULE_SIZE - 1), as this would be in 32 bits. Hence change the granule size's data type to size_t, so that the above value is not restricted to 32 bits. Bug 4650102 Change-Id: If44f2663b6a4735c193d3a80b233b53d70772335 Signed-off-by: Ketan Patil Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3149162 Reviewed-by: Sachin Nikam Tested-by: Bitan Biswas GVS: buildbot_gerritrpt --- drivers/video/tegra/nvmap/nvmap_init.c | 2 +- drivers/video/tegra/nvmap/nvmap_ioctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_init.c b/drivers/video/tegra/nvmap/nvmap_init.c index 4e4bc73c..92097fe1 100644 --- a/drivers/video/tegra/nvmap/nvmap_init.c +++ b/drivers/video/tegra/nvmap/nvmap_init.c @@ -498,7 +498,7 @@ void nvmap_dma_free_attrs(struct device *dev, size_t size, void *cpu_addr, struct dma_coherent_mem_replica *mem; bool is_gpu = false; const char *device_name; - u32 granule_size = 0; + size_t granule_size = 0; if (!dev || !dev->dma_mem) return; diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 46dc9354..d765a518 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -223,7 +223,7 @@ int nvmap_ioctl_alloc(struct file *filp, void __user *arg) * In case of Gpu carveout, the handle size needs to be aligned to granule. */ if (op.heap_mask & NVMAP_HEAP_CARVEOUT_GPU) { - u32 granule_size = 0; + size_t granule_size = 0; for (i = 0; i < nvmap_dev->nr_carveouts; i++) if (nvmap_dev->heaps[i].heap_bit & NVMAP_HEAP_CARVEOUT_GPU)