summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/perf/vfe_var.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2016-12-20 17:11:54 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-01-04 04:44:25 -0500
commitf37f4e27e362629d5c187817104d48d703c380cc (patch)
tree8dddaa1d926016848c6cebc4aa9f4a3612341da1 /drivers/gpu/nvgpu/perf/vfe_var.c
parent2a95a288b285b0eff16a8825298c416d185693fb (diff)
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 <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1279223 GVS: Gerrit_Virtual_Submit Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/perf/vfe_var.c')
-rw-r--r--drivers/gpu/nvgpu/perf/vfe_var.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/perf/vfe_var.c b/drivers/gpu/nvgpu/perf/vfe_var.c
index 4f8dc83b..f4c3f276 100644
--- a/drivers/gpu/nvgpu/perf/vfe_var.c
+++ b/drivers/gpu/nvgpu/perf/vfe_var.c
@@ -182,20 +182,21 @@ u32 dev_init_get_vfield_info(struct gk20a *g,
182 u8 *psegmentcount = NULL; 182 u8 *psegmentcount = NULL;
183 u32 status = 0; 183 u32 status = 0;
184 184
185 if (g->ops.bios.get_perf_table_ptrs) { 185 if (!g->ops.bios.get_perf_table_ptrs)
186 vfieldregtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, 186 return -EINVAL;
187 g->bios.virt_token, VP_FIELD_REGISTER);
188 if (vfieldregtableptr == NULL) {
189 status = -EINVAL;
190 goto done;
191 }
192 187
193 vfieldtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, 188 vfieldregtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
194 g->bios.virt_token, VP_FIELD_TABLE); 189 g->bios.virt_token, VP_FIELD_REGISTER);
195 if (vfieldtableptr == NULL) { 190 if (vfieldregtableptr == NULL) {
196 status = -EINVAL; 191 status = -EINVAL;
197 goto done; 192 goto done;
198 } 193 }
194
195 vfieldtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
196 g->bios.virt_token, VP_FIELD_TABLE);
197 if (vfieldtableptr == NULL) {
198 status = -EINVAL;
199 goto done;
199 } 200 }
200 201
201 memcpy(&vregheader, vfieldregtableptr, VFIELD_REG_HEADER_SIZE); 202 memcpy(&vregheader, vfieldregtableptr, VFIELD_REG_HEADER_SIZE);