Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/namespace: fix reference leak in grab_requested_mnt_ns

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>

authored by

Andrei Vagin and committed by
Christian Brauner
7b6dcd9b ac3fd01e

+4 -3
+4 -3
fs/namespace.c
··· 5746 5746 5747 5747 if (kreq->mnt_ns_id) { 5748 5748 mnt_ns = lookup_mnt_ns(kreq->mnt_ns_id); 5749 + if (!mnt_ns) 5750 + return ERR_PTR(-ENOENT); 5749 5751 } else if (kreq->mnt_ns_fd) { 5750 5752 struct ns_common *ns; 5751 5753 ··· 5763 5761 return ERR_PTR(-EINVAL); 5764 5762 5765 5763 mnt_ns = to_mnt_ns(ns); 5764 + refcount_inc(&mnt_ns->passive); 5766 5765 } else { 5767 5766 mnt_ns = current->nsproxy->mnt_ns; 5767 + refcount_inc(&mnt_ns->passive); 5768 5768 } 5769 - if (!mnt_ns) 5770 - return ERR_PTR(-ENOENT); 5771 5769 5772 - refcount_inc(&mnt_ns->passive); 5773 5770 return mnt_ns; 5774 5771 } 5775 5772