From: yebin <yebin@huaweicloud.com>
To: Zilin Guan <zilin@seu.edu.cn>, linkinjeon@kernel.org
Cc: smfrench@gmail.com, senozhatsky@chromium.org, tom@talpey.com,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] ksmbd: Fix memory leak in get_file_all_info()
Date: Thu, 25 Dec 2025 10:00:21 +0800 [thread overview]
Message-ID: <694C9AB5.9000009@huaweicloud.com> (raw)
In-Reply-To: <20251224142016.250752-1-zilin@seu.edu.cn>
On 2025/12/24 22:20, Zilin Guan wrote:
> 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>
> ---
> fs/smb/server/smb2pdu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 8aa483800014..4472638ab11a 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -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) {
goto out;
> + kfree(filename);
> return ret;
> + }
>
out:
kfree(filename);
return ret;
Maybe we can add 'out' label.
> ksmbd_debug(SMB, "filename = %s\n", filename);
> delete_pending = ksmbd_inode_pending_delete(fp);
>
prev parent reply other threads:[~2025-12-25 2:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 14:20 Zilin Guan
2025-12-25 1:59 ` Namjae Jeon
2025-12-25 2:00 ` yebin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=694C9AB5.9000009@huaweicloud.com \
--to=yebin@huaweicloud.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
--cc=zilin@seu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®