All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging/rdma/hfi1: Fix a possible null pointer dereference
@ 2015-12-10 16:13 Mike Marciniszyn
  2015-12-14 13:28   ` [Cocci] " Nicholas Mc Guire
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Marciniszyn @ 2015-12-10 16:13 UTC (permalink / raw)
  To: devel; +Cc: linux-rdma, dledford, linux-next

From: Easwar Hariharan <easwar.hariharan@intel.com>

A code inspection pointed out that kmalloc_array may return NULL and
memset doesn't check the input pointer for NULL, resulting in a possible
NULL dereference. This patch fixes this.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Easwar Hariharan <easwar.hariharan@intel.com>
---
 drivers/staging/rdma/hfi1/chip.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index dc69159..49d49b2 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -10129,6 +10129,8 @@ static void init_qos(struct hfi1_devdata *dd, u32 first_ctxt)
 	if (num_vls * qpns_per_vl > dd->chip_rcv_contexts)
 		goto bail;
 	rsmmap = kmalloc_array(NUM_MAP_REGS, sizeof(u64), GFP_KERNEL);
+	if (!rsmmap)
+		goto bail;
 	memset(rsmmap, rxcontext, NUM_MAP_REGS * sizeof(u64));
 	/* init the local copy of the table */
 	for (i = 0, ctxt = first_ctxt; i < num_vls; i++) {

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

end of thread, other threads:[~2015-12-20 12:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10 16:13 [PATCH] staging/rdma/hfi1: Fix a possible null pointer dereference Mike Marciniszyn
2015-12-14 13:28 ` Nicholas Mc Guire
2015-12-14 13:28   ` [Cocci] " Nicholas Mc Guire
2015-12-18  6:33   ` Julia Lawall
2015-12-18  6:33     ` Julia Lawall
     [not found]     ` <alpine.DEB.2.02.1512180727310.2052-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2015-12-18 14:20       ` Nicholas Mc Guire
2015-12-18 14:20         ` Nicholas Mc Guire
2015-12-20 12:59         ` Julia Lawall
2015-12-20 12:59           ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.