From 4d17d8b10431b1ba5775d35b34e76dbb8f9b448a Mon Sep 17 00:00:00 2001 From: Alvin Park Date: Tue, 15 Dec 2020 10:34:44 +0900 Subject: gpu: nvgpu: add check for is_railgated When try to read '/sys/kernel/debug/gpu.0/railgate_residency' debug fs node, NULL pointer access error can be happened if is_railgated function is not assinged. Add check for is_railgated before calling the function pointer. Bug 200773027 Change-Id: I914b5b0aa48ccb15affe79510b696ebc91129f67 Signed-off-by: Aditya Gupta Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2596320 (cherry picked from commit e649029c7bed3c7afbd454d7e94f9173377f4c64) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2614156 Tested-by: mobile promotions Reviewed-by: Rohit Upadhyay Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/debug.c b/drivers/gpu/nvgpu/os/linux/debug.c index d7e3f1e7..b8c45965 100644 --- a/drivers/gpu/nvgpu/os/linux/debug.c +++ b/drivers/gpu/nvgpu/os/linux/debug.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 NVIDIA Corporation. All rights reserved. + * Copyright (C) 2017-2021 NVIDIA Corporation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -224,7 +224,7 @@ static int railgate_residency_show(struct seq_file *s, void *data) unsigned long total_rail_gate_time_ms; unsigned long total_rail_ungate_time_ms; - if (platform->is_railgated && platform->is_railgated(dev_from_gk20a(g))) { + if (platform && platform->is_railgated && platform->is_railgated(dev_from_gk20a(g))) { time_since_last_state_transition_ms = jiffies_to_msecs(jiffies - g->pstats.last_rail_gate_complete); -- cgit v1.2.2