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

Mike Rapoport <[email protected]> Tue, 26 May 2026 12:06:57 +0300
Newsgroups org.kernel.vger.linux-nilfs,dev.linux.lists.ocfs2-devel,org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs,org.kvack.linux-mm
Message-ID <[email protected]>
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) <[email protected]>
> > ---
> >  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.
 
> 								Honza
> -- 
> Jan Kara <[email protected]>
> SUSE Labs, CR

-- 
Sincerely yours,
Mike.