video: tegra: nvmap: Fix stack frame size exceeded error in nvmap

Fix stack frame size exceeded error in nvmap_ioctl.c by allocating the buf array dynamically.

Bug 4663827

Change-Id: I4ccb86b2f82e09417bf957830777c516dcf1ee47
Signed-off-by: Yash Bhatt <ybhatt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3154936
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
Tested-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Yash Bhatt
2024-06-04 19:49:38 +00:00
committed by mobile promotions
parent 3cc7aea47d
commit 42585a86f3

View File

@@ -1161,7 +1161,7 @@ static int compute_memory_stat(u64 *total, u64 *free, int numa_id)
{
struct file *file;
char meminfo_path[64] = {'\0'};
u8 buf[MEMINFO_SIZE];
u8 *buf;
loff_t pos = 0;
char *buffer, *ptr;
u64 mem_total, mem_free, reclaimable;
@@ -1175,7 +1175,13 @@ static int compute_memory_stat(u64 *total, u64 *free, int numa_id)
return -EINVAL;
}
memset(buf, 0, sizeof(buf));
buf = nvmap_altalloc(MEMINFO_SIZE * sizeof(*buf));
if (!buf) {
pr_err("Memory allocation failed\n");
filp_close(file, NULL);
return -ENOMEM;
}
rc = kernel_read(file, buf, MEMINFO_SIZE - 1, &pos);
buf[rc] = '\n';
filp_close(file, NULL);
@@ -1192,6 +1198,7 @@ static int compute_memory_stat(u64 *total, u64 *free, int numa_id)
reclaimable_found = true;
}
nvmap_altfree(buf, MEMINFO_SIZE * sizeof(*buf));
if (nid == numa_id && total_found && free_found && reclaimable_found) {
*total = mem_total * 1024;
*free = (mem_free + reclaimable / 2) * 1024;