From c19c04644616f6262d40f0d66e48dc50c856b24b Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Wed, 8 Apr 2015 14:59:03 +0300 Subject: gpu: nvgpu: protect missing sgt in gk20a_mem_phys Return zero for missing sgt 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: Id8ce37798d6fd3ceeb96a3f521c82569fccf30aa Signed-off-by: Konsta Holtta Reviewed-on: http://git-master/r/729006 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/mm_gk20a.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h index 57f7a373..0ff11d09 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.h @@ -458,7 +458,9 @@ void gk20a_gmmu_free_attr(struct gk20a *g, static inline phys_addr_t gk20a_mem_phys(struct mem_desc *mem) { - return sg_phys(mem->sgt->sgl); + /* the sgt may get null if this is accessed e.g. in an isr during + * channel deletion */ + return mem->sgt ? sg_phys(mem->sgt->sgl) : 0; } u64 gk20a_locked_gmmu_map(struct vm_gk20a *vm, -- cgit v1.2.2