From 2e36ad9e35286653764dd1b25c270b36a154984f Mon Sep 17 00:00:00 2001 From: Rajesh Devaraj Date: Tue, 3 Jan 2023 06:39:38 +0000 Subject: [PATCH] gpu: nvgpu: add null check for gp_get, pb_get This patch adds NULL check for gp_get and pb_get. JIRA NVGPU-9325 Change-Id: If41c1c526c58a18cc91a95686e71bdfae9edb328 Signed-off-by: Rajesh Devaraj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2836366 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Tejal Kudav Reviewed-by: Seema Khowala GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/fifo/channel.c | 10 +++++++--- drivers/gpu/nvgpu/common/fifo/channel_wdt.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index aea277aeb..6b3d60bc9 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -1,7 +1,7 @@ /* * GK20A Graphics channel * - * Copyright (c) 2011-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2023, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -441,9 +441,13 @@ clean_up: static inline u32 channel_update_gpfifo_get(struct gk20a *g, struct nvgpu_channel *c) { - u32 new_get = g->ops.userd.gp_get(g, c); + u32 new_get = 0U; + + if (g->ops.userd.gp_get != NULL) { + new_get = g->ops.userd.gp_get(g, c); + c->gpfifo.get = new_get; + } - c->gpfifo.get = new_get; return new_get; } diff --git a/drivers/gpu/nvgpu/common/fifo/channel_wdt.c b/drivers/gpu/nvgpu/common/fifo/channel_wdt.c index 2d6382dde..92794ea6c 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel_wdt.c +++ b/drivers/gpu/nvgpu/common/fifo/channel_wdt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -51,8 +51,13 @@ static struct nvgpu_channel_wdt_state nvgpu_channel_collect_wdt_state( * accesses. The kernel mem for userd may not even exist; this * channel could be in usermode submit mode. */ - state.gp_get = g->ops.userd.gp_get(g, ch); - state.pb_get = g->ops.userd.pb_get(g, ch); + if (g->ops.userd.gp_get != NULL) { + state.gp_get = g->ops.userd.gp_get(g, ch); + } + + if (g->ops.userd.pb_get != NULL) { + state.pb_get = g->ops.userd.pb_get(g, ch); + } } return state;