public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] IB/ipath: add a range check before bumping the stats
@ 2013-03-12 11:03 Dan Carpenter
       [not found] ` <20130312110307.GA22921-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-03-12 11:03 UTC (permalink / raw)
  To: Mike Marciniszyn
  Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

My static checker complains that this could corrupt memory.  It
seems valid to add a range check here.

Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
I can't test this.

diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 439c35d..f15dd70 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -621,6 +621,10 @@ void ipath_ib_rcv(struct ipath_ibdev *dev, void *rhdr, void *data,
 	}
 
 	opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
+	if (opcode >= ARRAY_SIZE(dev->opstats)) {
+		dev->rcv_errors++;
+		goto bail;
+	}
 	dev->opstats[opcode].n_bytes += tlen;
 	dev->opstats[opcode].n_packets++;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-16 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 11:03 [patch] IB/ipath: add a range check before bumping the stats Dan Carpenter
     [not found] ` <20130312110307.GA22921-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2013-03-15 13:43   ` Marciniszyn, Mike
     [not found]     ` <32E1700B9017364D9B60AED9960492BC0D5C926B-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-03-16 10:25       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox