Skip to content

Commit 7390347

Browse files
rwnbiad105namjaejeon
authored andcommitted
ksmbd: fix a missing return value check bug
In the smb2_send_interim_resp(), if ksmbd_alloc_work_struct() fails to allocate a node, it returns a NULL pointer to the in_work pointer. This can lead to an illegal memory write of in_work->response_buf when allocate_interim_rsp_buf() attempts to perform a kzalloc() on it. To address this issue, incorporating a check for the return value of ksmbd_alloc_work_struct() ensures that the function returns immediately upon allocation failure, thereby preventing the aforementioned illegal memory access. Fixes: 041bba4414cd ("ksmbd: fix wrong interim response on compound") Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent c543b63 commit 7390347

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

smb2pdu.c

+3
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,9 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
701701
struct smb2_hdr *rsp_hdr;
702702
struct ksmbd_work *in_work = ksmbd_alloc_work_struct();
703703

704+
if (!in_work)
705+
return;
706+
704707
if (allocate_interim_rsp_buf(in_work)) {
705708
pr_err("smb_allocate_rsp_buf failed!\n");
706709
ksmbd_free_work_struct(in_work);

0 commit comments

Comments
 (0)