From 601fdeaed2b8f594c711bda4f94a294d325aff1b Mon Sep 17 00:00:00 2001 From: Yash Bhatt Date: Tue, 11 Jun 2024 06:40:07 +0000 Subject: [PATCH] video: tegra: nvmap: Remove WARN_ON and exit gracefully Remove WARN_ON macro invocation and exit gracefully from the nvmap_query_heap_params function when the heap_mask parameter is not a power of two. This is because if two or more bits are set in heap_mask, then it's an invalid parameter because NvMap can allocate buffer from only one heap at a time. Bug 4479038 Change-Id: I6cfca911115f7f29e2c4e46816a89fa1869adae4 Signed-off-by: Yash Bhatt Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3154939 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/video/tegra/nvmap/nvmap_ioctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 7410c805..7a6db822 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -1263,7 +1263,11 @@ static int nvmap_query_heap_params(void __user *arg, bool is_numa_aware) } type = op.heap_mask; - WARN_ON(type & (type - 1)); + if (type & (type - 1)) { + ret = -EINVAL; + goto exit; + } + if (is_numa_aware) numa_id = op.numa_id;