]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: Fix memory leak in get_file_all_info()
authorZilin Guan <zilin@seu.edu.cn>
Wed, 24 Dec 2025 14:20:16 +0000 (14:20 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:14:37 +0000 (10:14 +0100)
[ Upstream commit 0c56693b06a68476ba113db6347e7897475f9e4c ]

In get_file_all_info(), if vfs_getattr() fails, the function returns
immediately without freeing the allocated filename, leading to a memory
leak.

Fix this by freeing the filename before returning in this error case.

Fixes: 5614c8c487f6a ("ksmbd: replace generic_fillattr with vfs_getattr")
Signed-off-by: Zilin Guan <zilin@seu.edu.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 a1579f76e063f73fdc95af80471141ab13d2536b..e2cde9723001e5746df08405aecd534747b5c62d 100644 (file)
@@ -4926,8 +4926,10 @@ static int get_file_all_info(struct ksmbd_work *work,
 
        ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
                          AT_STATX_SYNC_AS_STAT);
-       if (ret)
+       if (ret) {
+               kfree(filename);
                return ret;
+       }
 
        ksmbd_debug(SMB, "filename = %s\n", filename);
        delete_pending = ksmbd_inode_pending_delete(fp);