From 9b5d328d2bf6c2cf47a3f6fd9d5188e2980710da Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Thu, 21 Sep 2023 15:40:06 +0900 Subject: [PATCH] ksmbd: check iov vector index in ksmbd_conn_write() 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 --- connection.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connection.c b/connection.c index 8827bbed2..876c0c179 100644 --- a/connection.c +++ b/connection.c @@ -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,