From 0db4570b5fc014b472bedb5c1490a5ce5d2f3f99 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Wed, 4 Jan 2017 12:41:18 -0800 Subject: gpu: nvgpu: Use perf table only if VBIOS supports it We retrieve perf table from VBIOS only if respective HAL op is implemented. Later in code we unconditionally dereference a pointer which can lead to NULL pointer access. Fix two new cases by early aborting creation of devinit tables if the perf VBIOS getter is missing. Bug 200192125 Change-Id: I30f20f1829305ecc1117c6301e26ff1b869967eb Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1280347 GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/perf/vfe_var.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/nvgpu/perf') diff --git a/drivers/gpu/nvgpu/perf/vfe_var.c b/drivers/gpu/nvgpu/perf/vfe_var.c index f43e68e2..65ede64a 100644 --- a/drivers/gpu/nvgpu/perf/vfe_var.c +++ b/drivers/gpu/nvgpu/perf/vfe_var.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2017, 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, @@ -868,14 +868,17 @@ static u32 devinit_get_vfe_var_table(struct gk20a *g, gk20a_dbg_info(""); - if (g->ops.bios.get_perf_table_ptrs) { - vfevars_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, - g->bios.perf_token, - CONTINUOUS_VIRTUAL_BINNING_TABLE); - if (vfevars_tbl_ptr == NULL) { - status = -EINVAL; - goto done; - } + if (!g->ops.bios.get_perf_table_ptrs) { + status = -EINVAL; + goto done; + } + + vfevars_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + g->bios.perf_token, + CONTINUOUS_VIRTUAL_BINNING_TABLE); + if (vfevars_tbl_ptr == NULL) { + status = -EINVAL; + goto done; } memcpy(&vfevars_tbl_header, vfevars_tbl_ptr, -- cgit v1.2.2