]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb/server: fix possible memory leak in smb2_read()
authorZhangGuoDong <zhangguodong@kylinos.cn>
Sat, 11 Oct 2025 16:47:59 +0000 (00:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Nov 2025 09:35:48 +0000 (10:35 +0100)
[ Upstream commit 6fced056d2cc8d01b326e6fcfabaacb9850b71a4 ]

Memory leak occurs when ksmbd_vfs_read() fails.
Fix this by adding the missing kvfree().

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/server/smb2pdu.c

index 796235cb956771ceee4cb3b6e27fb9c82d334c97..67021dc6dfd8197581ccf557b076a6b13b64dbff 100644 (file)
@@ -6782,6 +6782,7 @@ int smb2_read(struct ksmbd_work *work)
 
        nbytes = ksmbd_vfs_read(work, fp, length, &offset, aux_payload_buf);
        if (nbytes < 0) {
+               kvfree(aux_payload_buf);
                err = nbytes;
                goto out;
        }