Skip to content

Commit

Permalink
net/smc: fix double kfree in smc_listen_work()
Browse files Browse the repository at this point in the history
If smc_listen_rmda_finish() returns with an error, the storage
addressed by 'buf' is freed a second time.
Consolidate freeing under a common label and jump to that label.

Fixes: 6bb14e4 ("net/smc: dynamic allocation of CLC proposal buffer")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ursula Braun authored and David S. Miller committed Sep 18, 2020
1 parent 86d009f commit ac67936
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ static void smc_listen_work(struct work_struct *work)
}

/* finish worker */
kfree(buf);
if (!ism_supported) {
rc = smc_listen_rdma_finish(new_smc, &cclc,
ini.first_contact_local);
Expand All @@ -1381,12 +1380,13 @@ static void smc_listen_work(struct work_struct *work)
}
smc_conn_save_peer_info(new_smc, &cclc);
smc_listen_out_connected(new_smc);
return;
goto out_free;

out_unlock:
mutex_unlock(&smc_server_lgr_pending);
out_decl:
smc_listen_decline(new_smc, rc, ini.first_contact_local);
out_free:
kfree(buf);
}

Expand Down

0 comments on commit ac67936

Please sign in to comment.