diff mbox series

nfp: Fix passing zero to 'PTR_ERR'

Message ID 20201112145852.6580-1-yuehaibing@huawei.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series nfp: Fix passing zero to 'PTR_ERR' | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Yue Haibing Nov. 12, 2020, 2:58 p.m. UTC
nfp_cpp_from_nfp6000_pcie() returns ERR_PTR() and never returns
NULL. The NULL test should be removed, also return correct err.

Fixes: 63461a028f76 ("nfp: add the PF driver")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Simon Horman Nov. 12, 2020, 3:26 p.m. UTC | #1
On Thu, Nov 12, 2020 at 10:58:52PM +0800, YueHaibing wrote:
> nfp_cpp_from_nfp6000_pcie() returns ERR_PTR() and never returns
> NULL. The NULL test should be removed, also return correct err.
> 
> Fixes: 63461a028f76 ("nfp: add the PF driver")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Thanks, this does indeed seem to be the case.

Reviewed-by: Simon Horman <simon.horman@netronome.com>
Jakub Kicinski Nov. 12, 2020, 6:10 p.m. UTC | #2
On Thu, 12 Nov 2020 16:26:03 +0100 Simon Horman wrote:
> On Thu, Nov 12, 2020 at 10:58:52PM +0800, YueHaibing wrote:
> > nfp_cpp_from_nfp6000_pcie() returns ERR_PTR() and never returns
> > NULL. The NULL test should be removed, also return correct err.
> > 
> > Fixes: 63461a028f76 ("nfp: add the PF driver")
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>  
> 
> Thanks, this does indeed seem to be the case.
> 
> Reviewed-by: Simon Horman <simon.horman@netronome.com>

Thanks!

I'll drop the fixes tag and apply to net-next, though.
Unnecessary NULL-check is hardly a bug.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index 7ff2ccbd43b0..e672614d2906 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -724,10 +724,8 @@  static int nfp_pci_probe(struct pci_dev *pdev,
 	}
 
 	pf->cpp = nfp_cpp_from_nfp6000_pcie(pdev);
-	if (IS_ERR_OR_NULL(pf->cpp)) {
+	if (IS_ERR(pf->cpp)) {
 		err = PTR_ERR(pf->cpp);
-		if (err >= 0)
-			err = -ENOMEM;
 		goto err_disable_msix;
 	}