From 02834f8739be3d078b4b4e84162f3a9dcb8a2c27 Mon Sep 17 00:00:00 2001 From: srajum Date: Thu, 16 Mar 2023 15:07:28 +0530 Subject: [PATCH] gpu: nvgpu: fix CERT-C issues - CID 10165014 Dereference before null check - CID 10166579 Unused value Bug 3952896 Change-Id: I6a7f2b97b4a6519272607e560d09c138048bd665 Signed-off-by: srajum Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2872276 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Vaibhav Kachore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/nvs/nvs_sched_ctrl.c | 4 ++++ drivers/gpu/nvgpu/os/linux/ioctl_dbg.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/nvs/nvs_sched_ctrl.c b/drivers/gpu/nvgpu/common/nvs/nvs_sched_ctrl.c index 9db9b76aa..c86396a38 100644 --- a/drivers/gpu/nvgpu/common/nvs/nvs_sched_ctrl.c +++ b/drivers/gpu/nvgpu/common/nvs/nvs_sched_ctrl.c @@ -810,6 +810,10 @@ static int nvgpu_nvs_ctrl_fifo_scheduler_process_receiver(struct gk20a *g, { int result = 0; + if ((receiver_queue_sender == NULL) || (send_queue_receiver == NULL)) { + return -1; + } + (void)memset(receiver_queue_sender->internal_buffer, 0, NVS_DOMAIN_MESSAGE_MAX_PAYLOAD_SIZE); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c index 28b5408b7..131a903f2 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c @@ -1,7 +1,7 @@ /* * Tegra GK20A GPU Debugger/Profiler Driver * - * Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -2721,7 +2721,6 @@ static int nvgpu_dbg_gpu_access_gpu_va(struct dbg_session_gk20a *dbg_s, if (size > allocated_size) { if (buffer) { nvgpu_big_free(g, buffer); - buffer = NULL; } buffer = nvgpu_big_zalloc(g, size);