diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-01-04 15:41:18 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-01-06 12:13:59 -0500 |
commit | 0db4570b5fc014b472bedb5c1490a5ce5d2f3f99 (patch) | |
tree | 2071b0001e23fb95cf4797592055a3030ed0ebbf /drivers/gpu/nvgpu | |
parent | 7fd02cf343b8ba527865b64512fd684eb4bab313 (diff) |
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 <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1280347
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/clk/clk_prog.c | 19 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/perf/vfe_var.c | 21 |
2 files changed, 23 insertions, 17 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c index 22add3b0..d4876da8 100644 --- a/drivers/gpu/nvgpu/clk/clk_prog.c +++ b/drivers/gpu/nvgpu/clk/clk_prog.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -182,13 +182,16 @@ static u32 devinit_get_clk_prog_table(struct gk20a *g, | |||
182 | 182 | ||
183 | gk20a_dbg_info(""); | 183 | gk20a_dbg_info(""); |
184 | 184 | ||
185 | if (g->ops.bios.get_perf_table_ptrs) { | 185 | if (!g->ops.bios.get_perf_table_ptrs) { |
186 | clkprogs_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, | 186 | status = -EINVAL; |
187 | g->bios.clock_token, CLOCK_PROGRAMMING_TABLE); | 187 | goto done; |
188 | if (clkprogs_tbl_ptr == NULL) { | 188 | } |
189 | status = -EINVAL; | 189 | |
190 | goto done; | 190 | clkprogs_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, |
191 | } | 191 | g->bios.clock_token, CLOCK_PROGRAMMING_TABLE); |
192 | if (clkprogs_tbl_ptr == NULL) { | ||
193 | status = -EINVAL; | ||
194 | goto done; | ||
192 | } | 195 | } |
193 | 196 | ||
194 | memcpy(&header, clkprogs_tbl_ptr, hszfmt); | 197 | memcpy(&header, clkprogs_tbl_ptr, hszfmt); |
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 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * 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, | |||
868 | 868 | ||
869 | gk20a_dbg_info(""); | 869 | gk20a_dbg_info(""); |
870 | 870 | ||
871 | if (g->ops.bios.get_perf_table_ptrs) { | 871 | if (!g->ops.bios.get_perf_table_ptrs) { |
872 | vfevars_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, | 872 | status = -EINVAL; |
873 | g->bios.perf_token, | 873 | goto done; |
874 | CONTINUOUS_VIRTUAL_BINNING_TABLE); | 874 | } |
875 | if (vfevars_tbl_ptr == NULL) { | 875 | |
876 | status = -EINVAL; | 876 | vfevars_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, |
877 | goto done; | 877 | g->bios.perf_token, |
878 | } | 878 | CONTINUOUS_VIRTUAL_BINNING_TABLE); |
879 | if (vfevars_tbl_ptr == NULL) { | ||
880 | status = -EINVAL; | ||
881 | goto done; | ||
879 | } | 882 | } |
880 | 883 | ||
881 | memcpy(&vfevars_tbl_header, vfevars_tbl_ptr, | 884 | memcpy(&vfevars_tbl_header, vfevars_tbl_ptr, |