Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio/tsi721: fix queue wrapping bug in inbound doorbell handler

Fix a bug that causes a kernel panic when the number of received doorbells
is larger than number of entries in the inbound doorbell queue (current
default value = 512).

Another possible indication for this bug is large number of spurious
doorbells reported by tsi721 driver after reaching the queue size maximum.

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Chul Kim <chul.kim@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: <stable@vger.kernel.org> [3.2.x+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
b24823e6 e6ca7b89

+3 -2
+3 -2
drivers/rapidio/devices/tsi721.c
··· 410 410 */ 411 411 mport = priv->mport; 412 412 413 - wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)); 414 - rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE)); 413 + wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE; 414 + rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE)) % IDB_QSIZE; 415 415 416 416 while (wr_ptr != rd_ptr) { 417 417 idb_entry = (u64 *)(priv->idb_base + 418 418 (TSI721_IDB_ENTRY_SIZE * rd_ptr)); 419 419 rd_ptr++; 420 + rd_ptr %= IDB_QSIZE; 420 421 idb.msg = *idb_entry; 421 422 *idb_entry = 0; 422 423