Re: [PATCH 14/17] fs/namespace: use __getname() to allocate mntpath buffer

From: Christian Brauner

Date: Thu May 28 2026 - 07:54:52 EST


On Tue, May 26, 2026 at 12:06:57PM +0300, Mike Rapoport wrote:
> On Mon, May 25, 2026 at 06:22:13PM +0200, Jan Kara wrote:
> > On Sat 23-05-26 20:54:26, Mike Rapoport (Microsoft) wrote:
> > > 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().
> > >
> > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > > ---
> > > fs/namespace.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fs/namespace.c b/fs/namespace.c
> > > index fe919abd2f01..2ed9cd846a81 100644
> > > --- a/fs/namespace.c
> > > +++ b/fs/namespace.c
> > > @@ -3303,7 +3303,7 @@ 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();
> >
> > Fair but d_path() below should then get PATH_MAX and not PAGE_SIZE.
>
> Ack.
>
> > > if (buf)
> > > mntpath = d_path(mountpoint, buf, PAGE_SIZE);
> > > else
> > > @@ -3319,7 +3319,7 @@ static void mnt_warn_timestamp_expiry(const struct path *mountpoint,
> > >
> > > sb->s_iflags |= SB_I_TS_EXPIRY_WARNED;
> > > if (buf)
> > > - free_page((unsigned long)buf);
> > > + __putname(buf);
> >
> > And __putname() is fine with NULL so no need for the if (buf) check here.
>
> Will fix.

I've folded this myself.