]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/smc: fix using of uninitialized completions
authorKarsten Graul <kgraul@linux.ibm.com>
Mon, 27 Dec 2021 13:35:30 +0000 (14:35 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Dec 2021 14:46:17 +0000 (14:46 +0000)
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: 09c61d24f96d ("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>
net/smc/smc_wr.c

index 600ab58892271ff26ec744e3c15c7304f9652ea0..79a7431f534e2cb2d4fd1719fd530426b9d0da7f 100644 (file)
@@ -358,18 +358,20 @@ int smc_wr_tx_send_wait(struct smc_link *link, struct smc_wr_tx_pend_priv *priv,
                        unsigned long timeout)
 {
        struct smc_wr_tx_pend *pend;
+       u32 pnd_idx;
        int rc;
 
        pend = container_of(priv, struct smc_wr_tx_pend, priv);
        pend->compl_requested = 1;
-       init_completion(&link->wr_tx_compl[pend->idx]);
+       pnd_idx = pend->idx;
+       init_completion(&link->wr_tx_compl[pnd_idx]);
 
        rc = smc_wr_tx_send(link, priv);
        if (rc)
                return rc;
        /* wait for completion by smc_wr_tx_process_cqe() */
        rc = wait_for_completion_interruptible_timeout(
-                                       &link->wr_tx_compl[pend->idx], timeout);
+                                       &link->wr_tx_compl[pnd_idx], timeout);
        if (rc <= 0)
                rc = -ENODATA;
        if (rc > 0)