diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2015-04-30 06:30:05 -0400 |
---|---|---|
committer | Ishan Mittal <imittal@nvidia.com> | 2015-05-18 02:03:27 -0400 |
commit | 16fc6e3931733c9d5ff87e0b889aa2b897c540c3 (patch) | |
tree | a913bd5b4a621956a14fc0e063bdf06489f1db5b /drivers/gpu/nvgpu | |
parent | 520ff00e870eadc98a50f58ecd514ced53a8612f (diff) |
gpu: nvgpu: protect missing sgl in gk20a_mem_phys
Return zero for missing sgl (sgt is already checked) instead of
attempting to dereference NULL. Those NULL conditions should be almost
nonexistent, and zero is not normally used.
When reading gk20a_mem_phys() in gk20a_gr_get_chid_from_ctx() from an
isr, the mem desc may race with channel deletion and get suddendly
zeroed, even if the channel's in_use flag would be set. Plain zero
results in expected behaviour.
Change-Id: I7033979091951cba3e3004ddc7550cd327ad0baf
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/737759
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index e07b95fe..c1f8a4f0 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h | |||
@@ -464,9 +464,17 @@ void gk20a_gmmu_free_attr(struct gk20a *g, | |||
464 | 464 | ||
465 | static inline phys_addr_t gk20a_mem_phys(struct mem_desc *mem) | 465 | static inline phys_addr_t gk20a_mem_phys(struct mem_desc *mem) |
466 | { | 466 | { |
467 | /* the sgt may get null if this is accessed e.g. in an isr during | 467 | /* FIXME: the sgt/sgl may get null if this is accessed e.g. in an isr |
468 | * channel deletion */ | 468 | * during channel deletion - attempt to fix at least null derefs */ |
469 | return mem->sgt ? sg_phys(mem->sgt->sgl) : 0; | 469 | struct sg_table *sgt = mem->sgt; |
470 | |||
471 | if (sgt) { | ||
472 | struct scatterlist *sgl = sgt->sgl; | ||
473 | if (sgl) | ||
474 | return sg_phys(sgl); | ||
475 | } | ||
476 | |||
477 | return 0; | ||
470 | } | 478 | } |
471 | 479 | ||
472 | u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm, | 480 | u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm, |