Skip to content

Commit 1e11a39

Browse files
shirazsaleemjgunthorpe
authored andcommitted
RDMA/irdma: Fix a user-after-free in add_pble_prm
When irdma_hmc_sd_one fails, 'chunk' is freed while its still on the PBLE info list. Add the chunk entry to the PBLE info list only after successful setting of the SD in irdma_hmc_sd_one. Fixes: e8c4dbc ("RDMA/irdma: Add PBLE resource manager") Link: https://lore.kernel.org/r/20211207152135.2192-1-shiraz.saleem@intel.com Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 60a8b5a commit 1e11a39

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • drivers/infiniband/hw/irdma

drivers/infiniband/hw/irdma/pble.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc)
283283
"PBLE: next_fpm_addr = %llx chunk_size[%llu] = 0x%llx\n",
284284
pble_rsrc->next_fpm_addr, chunk->size, chunk->size);
285285
pble_rsrc->unallocated_pble -= (u32)(chunk->size >> 3);
286-
list_add(&chunk->list, &pble_rsrc->pinfo.clist);
287286
sd_reg_val = (sd_entry_type == IRDMA_SD_TYPE_PAGED) ?
288287
sd_entry->u.pd_table.pd_page_addr.pa :
289288
sd_entry->u.bp.addr.pa;
@@ -295,6 +294,7 @@ add_pble_prm(struct irdma_hmc_pble_rsrc *pble_rsrc)
295294
goto error;
296295
}
297296

297+
list_add(&chunk->list, &pble_rsrc->pinfo.clist);
298298
sd_entry->valid = true;
299299
return 0;
300300

0 commit comments

Comments
 (0)