Merge "net: qrtr: gunyah: Add bounds check on tx path"

This commit is contained in:
qctecmdr 2023-02-28 17:07:49 -08:00 committed by Gerrit - the friendly Code Review server
commit 37d4d91482

View File

@ -198,6 +198,9 @@ static size_t gunyah_tx_avail(struct gunyah_pipe *pipe)
else
avail -= FIFO_FULL_RESERVE;
if (WARN_ON_ONCE(head > pipe->length))
avail = 0;
return avail;
}
@ -208,6 +211,8 @@ static void gunyah_tx_write(struct gunyah_pipe *pipe, const void *data,
u32 head;
head = le32_to_cpu(*pipe->head);
if (WARN_ON_ONCE(head > pipe->length))
return;
len = min_t(size_t, count, pipe->length - head);
if (len)
@ -259,6 +264,8 @@ static void gunyah_sg_write(struct gunyah_pipe *pipe, struct scatterlist *sg,
int rc = 0;
head = le32_to_cpu(*pipe->head);
if (WARN_ON_ONCE(head > pipe->length))
return;
len = min_t(size_t, count, pipe->length - head);
if (len) {