diff mbox series

[net-next,2/7] bnxt_en: Remove a redundant NULL check in bnxt_register_dev()

Message ID 20240409215431.41424-3-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit 43226dccd1bd74c6bf97d8d357e782f4922d39e3
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Updates for net-next | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 942 this patch: 942
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 953 this patch: 953
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 953 this patch: 953
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan April 9, 2024, 9:54 p.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

The memory for "edev->ulp_tbl" is allocated inside the
bnxt_rdma_aux_device_init() function. If it fails, the driver
will not create the auxiliary device for RoCE. Hence the NULL
check inside bnxt_register_dev() is unnecessary.

Reviewed-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Jacob Keller April 9, 2024, 11:35 p.m. UTC | #1
On 4/9/2024 2:54 PM, Michael Chan wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> The memory for "edev->ulp_tbl" is allocated inside the
> bnxt_rdma_aux_device_init() function. If it fails, the driver
> will not create the auxiliary device for RoCE. Hence the NULL
> check inside bnxt_register_dev() is unnecessary.
> 
> Reviewed-by: Vikas Gupta <vikas.gupta@broadcom.com>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> index 86dcd2c76587..fd890819d4bc 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
> @@ -64,9 +64,6 @@ int bnxt_register_dev(struct bnxt_en_dev *edev,
>  		return -ENOMEM;
>  
>  	ulp = edev->ulp_tbl;
> -	if (!ulp)
> -		return -ENOMEM;
> -
>  	ulp->handle = handle;
>  	rcu_assign_pointer(ulp->ulp_ops, ulp_ops);
>  

Ok, so ulp_tbl is setup by bnxt_rdma_aux_device_init, and you're
claiming that the only way bnxt_register_dev gets called is if the
auxiliary driver loads?

But bnxt_register_dev is a simple direct-exported function, so the bnxt
driver itself doesn't enforce this. However, if we go look at the
infiniband driver that does call bnxt_register_dev, it only calls this
as part of its auxiliary device probe.

This does make the NULL check here seem redundant, though I think its a
lot more layered than a normal removal of a NULL check since this
crosses module boundary and its a bit subtle to follow the full flow of
the auxiliary drivers.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
index 86dcd2c76587..fd890819d4bc 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
@@ -64,9 +64,6 @@  int bnxt_register_dev(struct bnxt_en_dev *edev,
 		return -ENOMEM;
 
 	ulp = edev->ulp_tbl;
-	if (!ulp)
-		return -ENOMEM;
-
 	ulp->handle = handle;
 	rcu_assign_pointer(ulp->ulp_ops, ulp_ops);