Re: [PATCH] smb: client: free partially allocated transform folio queue

Steve French <[email protected]> Mon, 27 Jul 2026 17:35:57 -0500
Newsgroups gmane.linux.kernel,gmane.linux.kernel.cifs,gmane.network.samba.internals
Message-ID <CAH2r5ms7f0iOTS633Z=yvSfjwZY-L446GB8-fYebePyDoaOYgQ@mail.gmail.com>
Merged into cifs-2.6.git for-next

On Mon, Jul 27, 2026 at 8:41=E2=80=AFAM ChenXiaoSong
<[email protected]> wrote:
>
> Reviewed-by: ChenXiaoSong <[email protected]>
>
> =E5=9C=A8 2026/7/4 13:27, Yichong Chen =E5=86=99=E9=81=93:
> > netfs_alloc_folioq_buffer() may leave a partially allocated folio
> > queue attached to the caller's buffer pointer when it returns an error.
> >
> > smb3_init_transform_rq() stores the buffer in the request only after
> > allocation succeeds, so the common error path cannot free a partial
> > allocation. Store the buffer pointer before checking the return value s=
o
> > err_free releases it.
> >
> > Signed-off-by: Yichong Chen <[email protected]>
> > ---
> >   fs/smb/client/smb2ops.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
> > index 199f6aeb7b33..3fe9f0534e42 100644
> > --- a/fs/smb/client/smb2ops.c
> > +++ b/fs/smb/client/smb2ops.c
> > @@ -4882,10 +4882,10 @@ smb3_init_transform_rq(struct TCP_Server_Info *=
server, int num_rqst,
> >                       size_t cur_size =3D 0;
> >                       rc =3D netfs_alloc_folioq_buffer(NULL, &buffer, &=
cur_size,
> >                                                      size, GFP_NOFS);
> > +                     new->rq_buffer =3D buffer;
> >                       if (rc < 0)
> >                               goto err_free;
> >
> > -                     new->rq_buffer =3D buffer;
> >                       iov_iter_folio_queue(&new->rq_iter, ITER_SOURCE,
> >                                            buffer, 0, 0, size);
> >
>
> --
> ChenXiaoSong <[email protected]>
> Chinese Homepage: https://chenxiaosong.com
> English Homepage: https://chenxiaosong.com/en
>
>


--=20
Thanks,

Steve