smb/server: fix possible memory leak in smb2_read()

[ Upstream commit 6fced056d2 ]

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>
This commit is contained in:
ZhangGuoDong
2025-10-12 00:47:59 +08:00
committed by Greg Kroah-Hartman
parent d75079bbab
commit bfda5422a1

View File

@@ -6826,6 +6826,7 @@ int smb2_read(struct ksmbd_work *work)
nbytes = ksmbd_vfs_read(work, fp, length, &offset, aux_payload_buf); nbytes = ksmbd_vfs_read(work, fp, length, &offset, aux_payload_buf);
if (nbytes < 0) { if (nbytes < 0) {
kvfree(aux_payload_buf);
err = nbytes; err = nbytes;
goto out; goto out;
} }