Skip to content

Commit a67becd

Browse files
karstengrgregkh
authored andcommitted
net/smc: fix using of uninitialized completions
[ Upstream commit 6d7373d ] In smc_wr_tx_send_wait() the completion on index specified by pend->idx is initialized and after smc_wr_tx_send() was called the wait for completion starts. pend->idx is used to get the correct index for the wait, but the pend structure could already be cleared in smc_wr_tx_process_cqe(). Introduce pnd_idx to hold and use a local copy of the correct index. Fixes: 09c61d2 ("net/smc: wait for departure of an IB message") Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 769d14a commit a67becd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎net/smc/smc_wr.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,20 @@ int smc_wr_tx_send_wait(struct smc_link *link, struct smc_wr_tx_pend_priv *priv,
288288
unsigned long timeout)
289289
{
290290
struct smc_wr_tx_pend *pend;
291+
u32 pnd_idx;
291292
int rc;
292293

293294
pend = container_of(priv, struct smc_wr_tx_pend, priv);
294295
pend->compl_requested = 1;
295-
init_completion(&link->wr_tx_compl[pend->idx]);
296+
pnd_idx = pend->idx;
297+
init_completion(&link->wr_tx_compl[pnd_idx]);
296298

297299
rc = smc_wr_tx_send(link, priv);
298300
if (rc)
299301
return rc;
300302
/* wait for completion by smc_wr_tx_process_cqe() */
301303
rc = wait_for_completion_interruptible_timeout(
302-
&link->wr_tx_compl[pend->idx], timeout);
304+
&link->wr_tx_compl[pnd_idx], timeout);
303305
if (rc <= 0)
304306
rc = -ENODATA;
305307
if (rc > 0)

0 commit comments

Comments
 (0)