Skip to content

Commit 6d7373d

Browse files
karstengrdavem330
authored andcommitted
net/smc: fix using of uninitialized completions
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c1833c3 commit 6d7373d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/smc/smc_wr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,20 @@ int smc_wr_tx_send_wait(struct smc_link *link, struct smc_wr_tx_pend_priv *priv,
358358
unsigned long timeout)
359359
{
360360
struct smc_wr_tx_pend *pend;
361+
u32 pnd_idx;
361362
int rc;
362363

363364
pend = container_of(priv, struct smc_wr_tx_pend, priv);
364365
pend->compl_requested = 1;
365-
init_completion(&link->wr_tx_compl[pend->idx]);
366+
pnd_idx = pend->idx;
367+
init_completion(&link->wr_tx_compl[pnd_idx]);
366368

367369
rc = smc_wr_tx_send(link, priv);
368370
if (rc)
369371
return rc;
370372
/* wait for completion by smc_wr_tx_process_cqe() */
371373
rc = wait_for_completion_interruptible_timeout(
372-
&link->wr_tx_compl[pend->idx], timeout);
374+
&link->wr_tx_compl[pnd_idx], timeout);
373375
if (rc <= 0)
374376
rc = -ENODATA;
375377
if (rc > 0)

0 commit comments

Comments
 (0)