From 88a3a3d8d82d2842d0cffd90ee933aff2fcb8933 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Tue, 31 May 2022 15:37:32 +0530 Subject: [PATCH] gpu: nvgpu: assert the log type In __nvgpu_really_print_log: Guarantee that log type is valid before referring to the string from log_types. CID 393604 Change-Id: I22d5e68647ee36712157d988061191636cba4e4b Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2722480 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Sachin Nikam GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/log.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/log.c b/drivers/gpu/nvgpu/os/linux/log.c index 16e1f875c..110c66706 100644 --- a/drivers/gpu/nvgpu/os/linux/log.c +++ b/drivers/gpu/nvgpu/os/linux/log.c @@ -64,7 +64,10 @@ static void __nvgpu_really_print_log(u32 trace, const char *gpu_name, enum nvgpu_log_type type, const char *log) { const char *name = gpu_name ? gpu_name : ""; - const char *log_type = log_types[type]; + const char *log_type; + + nvgpu_assert(type >= NVGPU_ERROR && type <= NVGPU_INFO); + log_type = log_types[type]; #ifdef CONFIG_GK20A_TRACE_PRINTK if (trace)