Skip to content

Commit

Permalink
RDMA/iwcm: Fix iwcm work deallocation
Browse files Browse the repository at this point in the history
The dealloc_work_entries() function must update the work_free_list pointer
while freeing its entries, since potentially called again on same list. A
second iteration of the work list caused system crash. This happens, if
work allocation fails during cma_iw_listen() and free_cm_id() tries to
free the list again during cleanup.

Fixes: 922a8e9 ("RDMA: iWARP Connection Manager.")
Link: https://lore.kernel.org/r/20200302181614.17042-1-bmt@zurich.ibm.com
Reported-by: syzbot+cb0c054eabfba4342146@syzkaller.appspotmail.com
Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Bernard Metzler authored and Jason Gunthorpe committed Mar 4, 2020
1 parent 12e5eef commit 810dbc6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/infiniband/core/iwcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv)
{
struct list_head *e, *tmp;

list_for_each_safe(e, tmp, &cm_id_priv->work_free_list)
list_for_each_safe(e, tmp, &cm_id_priv->work_free_list) {
list_del(e);
kfree(list_entry(e, struct iwcm_work, free_list));
}
}

static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count)
Expand Down

0 comments on commit 810dbc6

Please sign in to comment.