projects
/
linux-2.6-microblaze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ac3fd01
)
fs/namespace: fix reference leak in grab_requested_mnt_ns
author
Andrei Vagin
<avagin@google.com>
Sat, 22 Nov 2025 07:19:53 +0000
(07:19 +0000)
committer
Christian Brauner
<brauner@kernel.org>
Tue, 25 Nov 2025 08:34:56 +0000
(09:34 +0100)
lookup_mnt_ns() already takes a reference on mnt_ns.
grab_requested_mnt_ns() doesn't need to take an extra reference.
Fixes:
78f0e33cd6c93
("fs/namespace: correctly handle errors returned by grab_requested_mnt_ns")
Signed-off-by: Andrei Vagin <avagin@google.com>
Link:
https://patch.msgid.link/20251122071953.3053755-1-avagin@google.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c
patch
|
blob
|
history
diff --git
a/fs/namespace.c
b/fs/namespace.c
index
2bad257
..
4272349
100644
(file)
--- a/
fs/namespace.c
+++ b/
fs/namespace.c
@@
-5746,6
+5746,8
@@
static struct mnt_namespace *grab_requested_mnt_ns(const struct mnt_id_req *kreq
if (kreq->mnt_ns_id) {
mnt_ns = lookup_mnt_ns(kreq->mnt_ns_id);
+ if (!mnt_ns)
+ return ERR_PTR(-ENOENT);
} else if (kreq->mnt_ns_fd) {
struct ns_common *ns;
@@
-5761,13
+5763,12
@@
static struct mnt_namespace *grab_requested_mnt_ns(const struct mnt_id_req *kreq
return ERR_PTR(-EINVAL);
mnt_ns = to_mnt_ns(ns);
+ refcount_inc(&mnt_ns->passive);
} else {
mnt_ns = current->nsproxy->mnt_ns;
+ refcount_inc(&mnt_ns->passive);
}
- if (!mnt_ns)
- return ERR_PTR(-ENOENT);
- refcount_inc(&mnt_ns->passive);
return mnt_ns;
}