]> 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)
committerSteve French <stfrench@microsoft.com>
Mon, 29 Dec 2025 23:39:57 +0000 (17:39 -0600)
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>
fs/smb/server/smb2pdu.c

index 469b70757dba613eeebe54866751c21826d6a1d1..a607e072a37012fc52674cbb86174290ffcab352 100644 (file)
@@ -4923,8 +4923,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);