Skip to content

Commit 0c56693

Browse files
GoodLuck612smfrench
authored andcommitted
ksmbd: Fix memory leak in get_file_all_info()
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: 5614c8c ("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>
1 parent f8f9c1f commit 0c56693

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4923,8 +4923,10 @@ static int get_file_all_info(struct ksmbd_work *work,
49234923

49244924
ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
49254925
AT_STATX_SYNC_AS_STAT);
4926-
if (ret)
4926+
if (ret) {
4927+
kfree(filename);
49274928
return ret;
4929+
}
49284930

49294931
ksmbd_debug(SMB, "filename = %s\n", filename);
49304932
delete_pending = ksmbd_inode_pending_delete(fp);

0 commit comments

Comments
 (0)