smb/server: fix some refcount leaks
Subsystems (2)
cover smb/server: fix some refcount leaks
From: ChenXiaoSong <[email protected]>
My dear team member, ZhangGuoDong, has caught some refcount leak issues.
Other patches pending review (including those from others) can be found at the following link:
https://chenxiaosong.com/en/smb-patch.html
ZhangGuoDong (2):
smb/server: fix refcount leak in parse_durable_handle_context() smb/server: fix refcount leak in smb2_open()
fs/smb/server/smb2pdu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH 1/2 smb/server: fix refcount leak in parse_durable_handle_context()
From: ZhangGuoDong <[email protected]>
When the command is a replay operation and -ENOEXEC is returned, the refcount of ksmbd_file must be released.
--- fs/smb/server/smb2pdu.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/server/smb2pdu.c +1 -0
@@ -2809,6 +2809,7 @@ static int parse_durable_handle_context(struct ksmbd_work *work, SMB2_CLIENT_GUID_SIZE)) {if (!(req->hdr.Flags &SMB2_FLAGS_REPLAY_OPERATION )) { err = -ENOEXEC ; +ksmbd_put_durable_fd (dh_info->fp); goto out; }
Signature · 1 line
2.43.0
Re: [PATCH 1/2] smb/server: fix refcount leak in parse_durable_handle_context()
Quoted 8 lines · On Mon, Dec 29, 2025 at 11:15 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
When the command is a replay operation and
-ENOEXECis returned, the refcount ofksmbd_filemust be released.Signed-off-by ZhangGuoDong <[email protected]>Signed-off-by ChenXiaoSong <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!
PATCH 2/2 smb/server: fix refcount leak in smb2_open()
In reply to [email protected]From: ZhangGuoDong <[email protected]>
When ksmbd_vfs_getattr() fails, the reference count of ksmbd_file must be released.
--- fs/smb/server/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +3 -1
@@ -3007,8 +3007,10 @@ int smb2_open(struct ksmbd_work *work) file_info =FILE_OPENED ; rc =ksmbd_vfs_getattr (&fp->filp->f_path, &stat); -if (rc) +if (rc) { +ksmbd_put_durable_fd (fp); goto err_out2; + }ksmbd_put_durable_fd (fp); goto reconnected_fp;
Signature · 1 line
2.43.0
Namjae Jeon
maintainerRe: [PATCH 2/2] smb/server: fix refcount leak in smb2_open()
Quoted 17 lines · On Mon, Dec 29, 2025 at 11:15 AM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
When
ksmbd_vfs_getattr()fails, the reference count ofksmbd_filemust be released.Signed-off-by ZhangGuoDong <[email protected]>Signed-off-by ChenXiaoSong <[email protected]>--- fs/smb/server/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/smb/server/smb2pdu.c +0
-0
fs/smb/server/smb2pdu.c int smb2_open(struct ksmbd_work *work) · line 3013
Quoted 8 lines
fs/smb/server/smb2pdu.c +3
-1@@ -3007,8 +3007,10 @@ int smb2_open(struct ksmbd_work *work) file_info =FILE_OPENED ; rc =ksmbd_vfs_getattr (&fp->filp->f_path, &stat); -if (rc) +if (rc) { +ksmbd_put_durable_fd (fp); goto err_out2; + }
I think that It is simpler to do it like this:
fs/smb/server/smb2pdu.c +1 -2
@@ -3009,10 +3009,9 @@ int smb2_open(struct ksmbd_work *work) file_info =FILE_OPENED ; rc =ksmbd_vfs_getattr (&fp->filp->f_path, &stat); +ksmbd_put_durable_fd (fp);if (rc) goto err_out2; - -ksmbd_put_durable_fd (fp); goto reconnected_fp; } }else if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE )
Quoted 6 lines
fs/smb/server/smb2pdu.c +0
-1ksmbd_put_durable_fd (fp); goto reconnected_fp; --2.43.0