diff mbox series

[net-internal,v2,2/8] ibmvnic: initialize rc before completing wait

Message ID 20220225040941.1429630-3-sukadev@linux.ibm.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ibmvnic: Fix a race in ibmvnic_probe() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: davem@davemloft.net; 7 maintainers not CCed: paulus@samba.org kuba@kernel.org benh@kernel.crashing.org mpe@ellerman.id.au linuxppc-dev@lists.ozlabs.org davem@davemloft.net tlfalcon@linux.ibm.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sukadev Bhattiprolu Feb. 25, 2022, 4:09 a.m. UTC
We should initialize ->init_done_rc before calling complete(). Otherwise
the waiting thread may see ->init_done_rc as 0 before we have updated it
and may assume that the CRQ was successful.

Fixes: 6b278c0cb378 ("ibmvnic delay complete()")
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Feb. 25, 2022, 5:15 a.m. UTC | #1
On Thu, 24 Feb 2022 20:09:35 -0800 Sukadev Bhattiprolu wrote:
> We should initialize ->init_done_rc before calling complete(). Otherwise
> the waiting thread may see ->init_done_rc as 0 before we have updated it
> and may assume that the CRQ was successful.
> 
> Fixes: 6b278c0cb378 ("ibmvnic delay complete()")

As you resend please fix to:

Fixes: 6b278c0cb378 ("ibmvnic: delay complete()")

There's a : missing.

Also in patch three make reinit_init_done() non-inline to keep with 
the netdev recommendations.
Sukadev Bhattiprolu Feb. 25, 2022, 6:44 p.m. UTC | #2
Jakub Kicinski [kuba@kernel.org] wrote:
> On Thu, 24 Feb 2022 20:09:35 -0800 Sukadev Bhattiprolu wrote:
> > We should initialize ->init_done_rc before calling complete(). Otherwise
> > the waiting thread may see ->init_done_rc as 0 before we have updated it
> > and may assume that the CRQ was successful.
> > 
> > Fixes: 6b278c0cb378 ("ibmvnic delay complete()")
> 
> As you resend please fix to:
> 
> Fixes: 6b278c0cb378 ("ibmvnic: delay complete()")
> 
> There's a : missing.

Ah sorry.

> 
> Also in patch three make reinit_init_done() non-inline to keep with 
> the netdev recommendations.

I had already resent and the patches were merged this morning.
Will send a patch to drop the inline.

Thanks

Sukadev
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 27a698171d67..830f3e45ec65 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -5319,9 +5319,9 @@  static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
 			}
 
 			if (!completion_done(&adapter->init_done)) {
-				complete(&adapter->init_done);
 				if (!adapter->init_done_rc)
 					adapter->init_done_rc = -EAGAIN;
+				complete(&adapter->init_done);
 			}
 
 			break;