Skip to content

Commit cd48a82

Browse files
JFleckjgunthorpe
authored andcommitted
IB/hfi1: Check for error on call to alloc_rsm_map_table
The call to alloc_rsm_map_table does not check if the kmalloc fails. Check for a NULL on alloc, and bail if it fails. Fixes: 372cc85 ("IB/hfi1: Extract RSM map table init from QOS") Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Reviewed-by: Mike Marciniszyn <[email protected]> Signed-off-by: John Fleck <[email protected]> Signed-off-by: Mike Marciniszyn <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 60c3bec commit cd48a82

File tree

1 file changed

+9
-2
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+9
-2
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14452,7 +14452,7 @@ void hfi1_deinit_vnic_rsm(struct hfi1_devdata *dd)
1445214452
clear_rcvctrl(dd, RCV_CTRL_RCV_RSM_ENABLE_SMASK);
1445314453
}
1445414454

14455-
static void init_rxe(struct hfi1_devdata *dd)
14455+
static int init_rxe(struct hfi1_devdata *dd)
1445614456
{
1445714457
struct rsm_map_table *rmt;
1445814458
u64 val;
@@ -14461,6 +14461,9 @@ static void init_rxe(struct hfi1_devdata *dd)
1446114461
write_csr(dd, RCV_ERR_MASK, ~0ull);
1446214462

1446314463
rmt = alloc_rsm_map_table(dd);
14464+
if (!rmt)
14465+
return -ENOMEM;
14466+
1446414467
/* set up QOS, including the QPN map table */
1446514468
init_qos(dd, rmt);
1446614469
init_fecn_handling(dd, rmt);
@@ -14487,6 +14490,7 @@ static void init_rxe(struct hfi1_devdata *dd)
1448714490
val |= ((4ull & RCV_BYPASS_HDR_SIZE_MASK) <<
1448814491
RCV_BYPASS_HDR_SIZE_SHIFT);
1448914492
write_csr(dd, RCV_BYPASS, val);
14493+
return 0;
1449014494
}
1449114495

1449214496
static void init_other(struct hfi1_devdata *dd)
@@ -15024,7 +15028,10 @@ int hfi1_init_dd(struct hfi1_devdata *dd)
1502415028
goto bail_cleanup;
1502515029

1502615030
/* set initial RXE CSRs */
15027-
init_rxe(dd);
15031+
ret = init_rxe(dd);
15032+
if (ret)
15033+
goto bail_cleanup;
15034+
1502815035
/* set initial TXE CSRs */
1502915036
init_txe(dd);
1503015037
/* set initial non-RXE, non-TXE CSRs */

0 commit comments

Comments
 (0)