Skip to content

Commit

Permalink
ksmbd: check iov vector index in ksmbd_conn_write()
Browse files Browse the repository at this point in the history
If ->iov_idx is zero, This means that the iov vector for the response
was not added during the request process. In other words, it means that
there is a problem in generating a response, So this patch return as
an error to avoid NULL pointer dereferencing problem.

Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Sep 21, 2023
1 parent fc7fb83 commit 9b5d328
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ int ksmbd_conn_write(struct ksmbd_work *work)
ksmbd_conn_unlock(conn);
}
#else
if (!work->iov_idx)
return -EINVAL;

ksmbd_conn_lock(conn);
sent = conn->transport->ops->writev(conn->transport, work->iov,
work->iov_cnt,
Expand Down

0 comments on commit 9b5d328

Please sign in to comment.