mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
video: tegra: nvmap: Fix kmemleak issues
While unloading the nvmap module, the memory allocated by following functions should be freed, otherwise it results into kmemleak: - nvmap_dma_init_coherent_memory - dev_set_name Bug 3860404 Change-Id: I7cd187c259ad2ceca0262154c0fb7fe8aedcfac8 Signed-off-by: Ketan Patil <ketanp@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2844474 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
76d402ab77
commit
afb7cce70c
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* GPU heap allocator.
|
* GPU heap allocator.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2022, NVIDIA Corporation. All rights reserved.
|
* Copyright (c) 2011-2023, NVIDIA Corporation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -535,6 +535,8 @@ struct nvmap_heap *nvmap_heap_create(struct device *parent,
|
|||||||
co->name, (void *)(uintptr_t)base, len/1024);
|
co->name, (void *)(uintptr_t)base, len/1024);
|
||||||
return h;
|
return h;
|
||||||
fail:
|
fail:
|
||||||
|
if (h->dma_dev->kobj.name)
|
||||||
|
kfree_const(h->dma_dev->kobj.name);
|
||||||
kfree(h);
|
kfree(h);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -543,6 +545,17 @@ fail:
|
|||||||
void nvmap_heap_destroy(struct nvmap_heap *heap)
|
void nvmap_heap_destroy(struct nvmap_heap *heap)
|
||||||
{
|
{
|
||||||
WARN_ON(!list_empty(&heap->all_list));
|
WARN_ON(!list_empty(&heap->all_list));
|
||||||
|
if (heap->dma_dev->kobj.name)
|
||||||
|
kfree_const(heap->dma_dev->kobj.name);
|
||||||
|
|
||||||
|
if (heap->is_ivm)
|
||||||
|
kfree(heap->name);
|
||||||
|
|
||||||
|
#ifdef NVMAP_LOADABLE_MODULE
|
||||||
|
nvmap_dma_release_coherent_memory((struct dma_coherent_mem_replica *)
|
||||||
|
heap->dma_dev->dma_mem);
|
||||||
|
#endif /* NVMAP_LOADABLE_MODULE */
|
||||||
|
|
||||||
while (!list_empty(&heap->all_list)) {
|
while (!list_empty(&heap->all_list)) {
|
||||||
struct list_block *l;
|
struct list_block *l;
|
||||||
l = list_first_entry(&heap->all_list, struct list_block,
|
l = list_first_entry(&heap->all_list, struct list_block,
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ void nvmap_dma_mark_declared_memory_unoccupied(struct device *dev,
|
|||||||
spin_unlock_irqrestore(&mem->spinlock, flags);
|
spin_unlock_irqrestore(&mem->spinlock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvmap_dma_release_coherent_memory(struct dma_coherent_mem_replica *mem)
|
void nvmap_dma_release_coherent_memory(struct dma_coherent_mem_replica *mem)
|
||||||
{
|
{
|
||||||
if (!mem)
|
if (!mem)
|
||||||
return;
|
return;
|
||||||
@@ -727,15 +727,9 @@ static int __init nvmap_co_device_init(struct reserved_mem *rmem,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nvmap_co_device_release(struct reserved_mem *rmem,struct device *dev)
|
static void nvmap_co_device_release(struct reserved_mem *rmem, struct device *dev)
|
||||||
{
|
{
|
||||||
struct nvmap_platform_carveout *co = rmem->priv;
|
|
||||||
|
|
||||||
if (!co)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (co->usage_mask == NVMAP_HEAP_CARVEOUT_IVM)
|
|
||||||
kfree(co->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct reserved_mem_ops nvmap_co_ops = {
|
static const struct reserved_mem_ops nvmap_co_ops = {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* GPU memory management driver for Tegra
|
* GPU memory management driver for Tegra
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009-2022, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2009-2023, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -926,4 +926,8 @@ extern void __dma_map_area(const void *cpu_va, size_t size, int dir);
|
|||||||
int nvmap_assign_pages_to_handle(struct nvmap_client *client,
|
int nvmap_assign_pages_to_handle(struct nvmap_client *client,
|
||||||
struct nvmap_handle **hs, struct nvmap_handle *h,
|
struct nvmap_handle **hs, struct nvmap_handle *h,
|
||||||
struct handles_range *rng);
|
struct handles_range *rng);
|
||||||
|
|
||||||
|
#ifdef NVMAP_LOADABLE_MODULE
|
||||||
|
void nvmap_dma_release_coherent_memory(struct dma_coherent_mem_replica *mem);
|
||||||
|
#endif /* NVMAP_LOADABLE_MODULE */
|
||||||
#endif /* __VIDEO_TEGRA_NVMAP_NVMAP_H */
|
#endif /* __VIDEO_TEGRA_NVMAP_NVMAP_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user