summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2025-11-02 08:01:47 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2026-01-13 23:18:07 +0300
commit741c97fecb6a4160014a76759e9b8c0880fc44f1 (patch)
tree72bd86a8d2455ae66dc6cc9d3b830bae980da91e /fs
parent9fa3ec84587c5eca7580eafc27eee332bc3a5a0e (diff)
downloadlinux-741c97fecb6a4160014a76759e9b8c0880fc44f1.tar.xz
struct filename ->refcnt doesn't need to be atomic
... or visible outside of audit, really. Note that references held in delayed_filename always have refcount 1, and from the moment of complete_getname() or equivalent point in getname...() there won't be any references to struct filename instance left in places visible to other threads. Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b76cc43fe89d..f4359825ba48 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -150,7 +150,7 @@ static inline void free_filename(struct filename *p)
static inline void initname(struct filename *name)
{
name->aname = NULL;
- atomic_set(&name->refcnt, 1);
+ name->refcnt = 1;
}
static int getname_long(struct filename *name, const char __user *filename)
@@ -292,13 +292,13 @@ void putname(struct filename *name)
if (IS_ERR_OR_NULL(name))
return;
- refcnt = atomic_read(&name->refcnt);
+ refcnt = name->refcnt;
if (unlikely(refcnt != 1)) {
if (WARN_ON_ONCE(!refcnt))
return;
- if (!atomic_dec_and_test(&name->refcnt))
- return;
+ name->refcnt--;
+ return;
}
if (unlikely(name->name != name->iname))
@@ -328,12 +328,12 @@ int delayed_getname_uflags(struct delayed_filename *v, const char __user *string
int putname_to_delayed(struct delayed_filename *v, struct filename *name)
{
- if (likely(atomic_read(&name->refcnt) == 1)) {
+ if (likely(name->refcnt == 1)) {
v->__incomplete_filename = name;
return 0;
}
+ name->refcnt--;
v->__incomplete_filename = do_getname_kernel(name->name, true);
- putname(name);
return PTR_ERR_OR_ZERO(v->__incomplete_filename);
}