From c2d01257d79e52a6f4e0ae4335df1b125284accf Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Tue, 27 Feb 2018 15:13:59 -0800 Subject: gpu: nvgpu: WARN_ON dma_alloc if mem is already valid Trying to alloc mem for already valid mem will dump warn stack along with nvgpu warn message for memory leak. Bug 200393029 Change-Id: I9b5becf898deb47eecd6369c2a97e688caa4660e Signed-off-by: Seema Khowala Reviewed-on: https://git-master.nvidia.com/r/1665377 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade Reviewed-by: Alex Waterman Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/dma.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index c13dae8b..c111d22b 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -221,6 +221,11 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, NVGPU_DEFINE_DMA_ATTRS(dma_attrs); void *alloc_ret; + if (nvgpu_mem_is_valid(mem)) { + nvgpu_warn(g, "memory leak !!"); + WARN_ON(1); + } + /* * Before the debug print so we see this in the total. But during * cleanup in the fail path this has to be subtracted. @@ -297,6 +302,11 @@ int nvgpu_dma_alloc_flags_vid_at(struct gk20a *g, unsigned long flags, &g->mm.vidmem.bootstrap_allocator; int before_pending; + if (nvgpu_mem_is_valid(mem)) { + nvgpu_warn(g, "memory leak !!"); + WARN_ON(1); + } + dma_dbg_alloc(g, size, flags, "vidmem"); mem->size = size; -- cgit v1.2.2