Skip to content

Commit

Permalink
net/smc: remove freed buffer from list
Browse files Browse the repository at this point in the history
Two buffers are allocated for each SMC connection. Each buffer is
added to a buffer list after creation. When the second buffer
allocation fails, the first buffer is freed but not deleted from
the list. This might result in crashes when another connection picks
up the freed buffer later and starts to work with it.

Reviewed-by: Ursula Braun <ubraun@linux.ibm.com>
Fixes: 6511aad ("net/smc: change smc_buf_free function parameters")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
karstengr authored and davem330 committed Jul 19, 2020
1 parent 741a49a commit fd7f3a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/smc/smc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1772,8 +1772,12 @@ int smc_buf_create(struct smc_sock *smc, bool is_smcd)
return rc;
/* create rmb */
rc = __smc_buf_create(smc, is_smcd, true);
if (rc)
if (rc) {
mutex_lock(&smc->conn.lgr->sndbufs_lock);
list_del(&smc->conn.sndbuf_desc->list);
mutex_unlock(&smc->conn.lgr->sndbufs_lock);
smc_buf_free(smc->conn.lgr, false, smc->conn.sndbuf_desc);
}
return rc;
}

Expand Down

0 comments on commit fd7f3a7

Please sign in to comment.