Commit 859bcad9 authored by Easwar Hariharan's avatar Easwar Hariharan Committed by Greg Kroah-Hartman

staging/rdma/hfi1: Fix a possible null pointer dereference

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: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarEaswar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5cd24119
...@@ -13358,6 +13358,8 @@ static void init_qos(struct hfi1_devdata *dd, u32 first_ctxt) ...@@ -13358,6 +13358,8 @@ static void init_qos(struct hfi1_devdata *dd, u32 first_ctxt)
if (num_vls * qpns_per_vl > dd->chip_rcv_contexts) if (num_vls * qpns_per_vl > dd->chip_rcv_contexts)
goto bail; goto bail;
rsmmap = kmalloc_array(NUM_MAP_REGS, sizeof(u64), GFP_KERNEL); rsmmap = kmalloc_array(NUM_MAP_REGS, sizeof(u64), GFP_KERNEL);
if (!rsmmap)
goto bail;
memset(rsmmap, rxcontext, NUM_MAP_REGS * sizeof(u64)); memset(rsmmap, rxcontext, NUM_MAP_REGS * sizeof(u64));
/* init the local copy of the table */ /* init the local copy of the table */
for (i = 0, ctxt = first_ctxt; i < num_vls; i++) { for (i = 0, ctxt = first_ctxt; i < num_vls; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment