netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net/smc: fix using of uninitialized completions
@ 2021-12-27 13:35 Karsten Graul
  2021-12-27 14:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Karsten Graul @ 2021-12-27 13:35 UTC (permalink / raw)
  To: David Miller, Jakub Kicinski; +Cc: netdev, linux-s390, Heiko Carstens

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>
---
 net/smc/smc_wr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index 600ab5889227..79a7431f534e 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -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)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net/smc: fix using of uninitialized completions
  2021-12-27 13:35 [PATCH net] net/smc: fix using of uninitialized completions Karsten Graul
@ 2021-12-27 14:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-27 14:50 UTC (permalink / raw)
  To: Karsten Graul; +Cc: davem, kuba, netdev, linux-s390, hca

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 27 Dec 2021 14:35:30 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net/smc: fix using of uninitialized completions
    https://git.kernel.org/netdev/net/c/6d7373dabfd3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-27 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-27 13:35 [PATCH net] net/smc: fix using of uninitialized completions Karsten Graul
2021-12-27 14:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).