summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Metzler <bmt@zurich.ibm.com>2020-03-02 19:16:14 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-11 18:03:07 +0100
commit8457a77611f784abb4b02d01e0e97a1ad3139c8c (patch)
treea3991a5ad6d91f39ccbdc62d815a03086d2e009c
parent9b2c4c1b2c114c3bbe69351a91213f2aa204a6fc (diff)
downloadlinux-8457a77611f784abb4b02d01e0e97a1ad3139c8c.tar.gz
linux-8457a77611f784abb4b02d01e0e97a1ad3139c8c.tar.bz2
linux-8457a77611f784abb4b02d01e0e97a1ad3139c8c.zip
RDMA/iwcm: Fix iwcm work deallocation
commit 810dbc69087b08fd53e1cdd6c709f385bc2921ad upstream. 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: 922a8e9fb2e0 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/infiniband/core/iwcm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 30d7277249b8..16b0c10348e8 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -158,8 +158,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)