summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-09-13 17:03:34 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-19 02:15:51 -0400
commitc03ccd89c24572dcb65bdfc8d9ab5eb76da28c96 (patch)
tree8df70ca726b17749eeb034672231db46a1f7fb63 /drivers/gpu/nvgpu/common
parent838ba0a14d61ffde0d8631d1c6267694632234de (diff)
gpu: nvgpu: Add nvgpu_mem_is_valid() call
Add a function to check if an nvgpu_mem is allocated (valid) or not. Also fix possibly leaked state in nvgpu_mems when they fail to allocate. Also ensure that in the case of a failure to allocate no state is accidentally leaked to the caller. This should hopefully make it less likely that a caller thinks a buffer that failed to allocate is actually allocated. Change-Id: I43224ece7da84e63b2f43f36f04941126fabf3c7 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1559419 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r--drivers/gpu/nvgpu/common/linux/dma.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c
index 13c1c347..43009fca 100644
--- a/drivers/gpu/nvgpu/common/linux/dma.c
+++ b/drivers/gpu/nvgpu/common/linux/dma.c
@@ -167,6 +167,7 @@ fail_free:
167 dma_free_coherent(d, size, mem->cpu_va, iova); 167 dma_free_coherent(d, size, mem->cpu_va, iova);
168 mem->cpu_va = NULL; 168 mem->cpu_va = NULL;
169 mem->priv.sgt = NULL; 169 mem->priv.sgt = NULL;
170 mem->size = 0;
170 return err; 171 return err;
171} 172}
172 173
@@ -253,6 +254,7 @@ fail_kfree:
253 nvgpu_kfree(g, mem->priv.sgt); 254 nvgpu_kfree(g, mem->priv.sgt);
254fail_physfree: 255fail_physfree:
255 nvgpu_free(&g->mm.vidmem.allocator, addr); 256 nvgpu_free(&g->mm.vidmem.allocator, addr);
257 mem->size = 0;
256 return err; 258 return err;
257#else 259#else
258 return -ENOSYS; 260 return -ENOSYS;