]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: free partially allocated transform folio queue
authorYichong Chen <chenyichong@uniontech.com>
Sat, 4 Jul 2026 05:27:14 +0000 (13:27 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 27 Jul 2026 22:25:58 +0000 (17:25 -0500)
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 so
err_free releases it.

Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb2ops.c

index cbd51a08e97e6e334e1da867e8664f257838945f..192649fec25d54cd6405a0e5150c2fdbd353d76e 100644 (file)
@@ -4745,10 +4745,10 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,
                        size_t cur_size = 0;
                        rc = netfs_alloc_folioq_buffer(NULL, &buffer, &cur_size,
                                                       size, GFP_NOFS);
+                       new->rq_buffer = buffer;
                        if (rc < 0)
                                goto err_free;
 
-                       new->rq_buffer = buffer;
                        iov_iter_folio_queue(&new->rq_iter, ITER_SOURCE,
                                             buffer, 0, 0, size);