diff --git a/net/qrtr/haven.c b/net/qrtr/haven.c index b37e779c7e7f..02719209782f 100644 --- a/net/qrtr/haven.c +++ b/net/qrtr/haven.c @@ -188,6 +188,9 @@ static size_t haven_tx_avail(struct haven_pipe *pipe) else avail -= FIFO_FULL_RESERVE; + if (WARN_ON_ONCE(avail > pipe->length)) + avail = 0; + return avail; } @@ -198,6 +201,8 @@ static void haven_tx_write(struct haven_pipe *pipe, 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)