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 issue
get_task_struct increment the ref count over task struct, and it will be decremented as part of put_task_struct. task_struct won't be freed unless it's refcount becomes 0. Hence the missing put_task_struct in nvmap code was resulting into kmemleak. Fix it by add this missing call. Also, mutex_unlock was missing in one of the return path, add it. Bug 3901618 Change-Id: I630eac19e628a549179a8ddaad86ad4d2c9b9a53 Signed-off-by: Ketan Patil <ketanp@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2837383 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: Ashish Mhetre <amhetre@nvidia.com> Reviewed-by: Sachin Nikam <snikam@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
85f7def3a6
commit
e3a44ab6e8
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* User-space interface to nvmap
|
||||
*
|
||||
* 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
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
@@ -223,6 +223,7 @@ struct nvmap_client *__nvmap_create_client(struct nvmap_device *dev,
|
||||
if (nvmap_client_pid(client) == pid) {
|
||||
/* Increment counter to track number of namespaces of a process */
|
||||
atomic_add(1, &client->count);
|
||||
put_task_struct(current->group_leader);
|
||||
is_existing_client = true;
|
||||
goto unlock;
|
||||
}
|
||||
@@ -234,8 +235,10 @@ unlock:
|
||||
}
|
||||
|
||||
client = kzalloc(sizeof(*client), GFP_KERNEL);
|
||||
if (!client)
|
||||
if (!client) {
|
||||
mutex_unlock(&dev->clients_lock);
|
||||
return NULL;
|
||||
}
|
||||
client->name = name;
|
||||
client->handle_refs = RB_ROOT;
|
||||
client->task = task;
|
||||
|
||||
Reference in New Issue
Block a user