]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/namespace: use __getname() to allocate mntpath buffer
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sat, 23 May 2026 17:54:26 +0000 (20:54 +0300)
committerChristian Brauner <brauner@kernel.org>
Thu, 28 May 2026 11:57:57 +0000 (13:57 +0200)
mnt_warn_timestamp_expiry() allocates memory for a path with
__get_free_page() although there is a dedicated helper for allocation of
file paths: __getname().

Replace __get_free_page() for allocation of a path buffer with __getname().

Christian Brauner <brauner@kernel.org> says:

Pass PATH_MAX (not PAGE_SIZE) to d_path() to match the size that
__getname() actually allocates, and drop the now-unnecessary NULL check
around __putname() since __putname() handles NULL.  Both per Jan Kara's
review feedback, acked by the author.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Link: https://patch.msgid.link/20260523-b4-fs-v1-14-275e36a83f0e@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/namespace.c

index fe919abd2f0118594a4ab7e593648c7c629a6544..d67c2f61b3dfd2cd3f6d2129c8509b87e0da77e5 100644 (file)
@@ -3303,9 +3303,9 @@ static void mnt_warn_timestamp_expiry(const struct path *mountpoint,
           (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) {
                char *buf, *mntpath;
 
-               buf = (char *)__get_free_page(GFP_KERNEL);
+               buf = __getname();
                if (buf)
-                       mntpath = d_path(mountpoint, buf, PAGE_SIZE);
+                       mntpath = d_path(mountpoint, buf, PATH_MAX);
                else
                        mntpath = ERR_PTR(-ENOMEM);
                if (IS_ERR(mntpath))
@@ -3318,8 +3318,7 @@ static void mnt_warn_timestamp_expiry(const struct path *mountpoint,
                        (unsigned long long)sb->s_time_max);
 
                sb->s_iflags |= SB_I_TS_EXPIRY_WARNED;
-               if (buf)
-                       free_page((unsigned long)buf);
+               __putname(buf);
        }
 }