From f37f4e27e362629d5c187817104d48d703c380cc Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 20 Dec 2016 14:11:54 -0800 Subject: gpu: nvgpu: Use perf table only VBIOS supports it We retrieve perf table from VBIOS only if respective HAL op is implemented. Later in code we unconditionally dereference the pointer which can lead to NULL pointer access. Fix by early aborting creation of devinit tables if the perf VBIOS getter is missing. Change-Id: If48aa6dac724056dd1feb2ef520e343736d4db85 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1279223 GVS: Gerrit_Virtual_Submit Reviewed-by: Thomas Fleury --- drivers/gpu/nvgpu/pmgr/pwrdev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/nvgpu/pmgr/pwrdev.c') diff --git a/drivers/gpu/nvgpu/pmgr/pwrdev.c b/drivers/gpu/nvgpu/pmgr/pwrdev.c index 03e2eb34..da034b31 100644 --- a/drivers/gpu/nvgpu/pmgr/pwrdev.c +++ b/drivers/gpu/nvgpu/pmgr/pwrdev.c @@ -140,13 +140,14 @@ static u32 devinit_get_pwr_device_table(struct gk20a *g, gk20a_dbg_info(""); - if (g->ops.bios.get_perf_table_ptrs != NULL) { - pwr_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, - g->bios.perf_token, POWER_SENSORS_TABLE); - if (pwr_device_table_ptr == NULL) { - status = -EINVAL; - goto done; - } + if (!g->ops.bios.get_perf_table_ptrs) + return -EINVAL; + + pwr_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + g->bios.perf_token, POWER_SENSORS_TABLE); + if (pwr_device_table_ptr == NULL) { + status = -EINVAL; + goto done; } memcpy(&pwr_sensor_table_header, pwr_device_table_ptr, -- cgit v1.2.2