From: Namjae Jeon Date: Wed, 26 May 2021 06:31:37 +0000 (+0900) Subject: cifsd: add the check if nvec is zero X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=41a7848a01b3f4401b8b87815e643584b86895f2;p=linux.git cifsd: add the check if nvec is zero Dan Carpenter pointed out that memory can be corrupted when nvec is zero. This patch add the check to prevent it. Reviewed-by: Dan Carpenter Signed-off-by: Namjae Jeon Signed-off-by: Steve French --- diff --git a/fs/cifsd/auth.c b/fs/cifsd/auth.c index 7e56966f87d41..9f957c8c123c5 100644 --- a/fs/cifsd/auth.c +++ b/fs/cifsd/auth.c @@ -1172,6 +1172,9 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec, unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 24; int i, nr_entries[3] = {0}, total_entries = 0, sg_idx = 0; + if (!nvec) + return NULL; + for (i = 0; i < nvec - 1; i++) { unsigned long kaddr = (unsigned long)iov[i + 1].iov_base;