From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: liuqiangneo@163.com, linkinjeon@kernel.org, smfrench@gmail.com,
senozhatsky@chromium.org, tom@talpey.com
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Qiang Liu <liuqiang@kylinos.cn>
Subject: Re: [PATCH 3/3] ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr
Date: Tue, 23 Jun 2026 10:46:40 +0800 [thread overview]
Message-ID: <eccbd78b-d400-4261-887f-6f21fdc51bd2@chenxiaosong.com> (raw)
In-Reply-To: <20260623021240.34722-4-liuqiangneo@163.com>
We can add a label and use `goto` to free n.data
On 6/23/26 10:12, liuqiangneo@163.com wrote:
> From: Qiang Liu <liuqiang@kylinos.cn>
>
> Free ndr buffer data when ndr_encode_dos_attr() returns error
> to avoid memory leak.
>
> Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
> ---
> fs/smb/server/vfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index 60b4210d5ab8..18d5412081de 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -1568,8 +1568,10 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
> int err;
>
> err = ndr_encode_dos_attr(&n, da);
> - if (err)
> + if (err) {
> + kfree(n.data);
> return err;
> + }
>
> err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
> (void *)n.data, n.offset, 0, get_write);
--
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
prev parent reply other threads:[~2026-06-23 2:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 2:12 [PATCH 0/3] ksmbd: fix some memory leaks in ksmbd_vfs_* functions liuqiangneo
2026-06-23 2:12 ` [PATCH 1/3] ksmbd: fix sd_ndr.data memory leak in ksmbd_vfs_set_sd_xattr liuqiangneo
2026-06-23 2:28 ` ChenXiaoSong
2026-06-23 2:12 ` [PATCH 2/3] ksmbd: fix acl.sd_buf memory leak in ksmbd_vfs_get_sd_xattr liuqiangneo
2026-06-23 2:44 ` ChenXiaoSong
2026-06-23 2:12 ` [PATCH 3/3] ksmbd: fix n.data memory leak in ksmbd_vfs_set_dos_attrib_xattr liuqiangneo
2026-06-23 2:46 ` ChenXiaoSong [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=eccbd78b-d400-4261-887f-6f21fdc51bd2@chenxiaosong.com \
--to=chenxiaosong@chenxiaosong.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuqiang@kylinos.cn \
--cc=liuqiangneo@163.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=tom@talpey.com \
/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®