Re: [PATCH] Octeontx2-af: Fix missing error code in cgx_probe()

From: Paolo Abeni

Date: Tue Oct 14 2025 - 05:47:18 EST




On 10/10/25 10:42 PM, Harshit Mogalapalli wrote:
> When CGX fails mapping to NIX, set the error code to -ENODEV, currently
> err is zero and that is treated as success path.
>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/aLAdlCg2_Yv7Y-3h@stanley.mountain/
> Fixes: d280233fc866 ("Octeontx2-af: Fix NIX X2P calibration failures")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>
> ---
> This is based on static analysis with smatch and only compile tested.
> ---
> drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> index d374a4454836..ec0e11c77cbf 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> @@ -1981,6 +1981,7 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> !is_cgx_mapped_to_nix(pdev->subsystem_device, cgx->cgx_id)) {
> dev_notice(dev, "CGX %d not mapped to NIX, skipping probe\n",
> cgx->cgx_id);
> + err = -ENODEV;
> goto err_release_regions;
> }
>

Side note, a few lines below there is this check:

err = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_MSIX);
if (err < 0 || err != nvec) {
dev_err(dev, "Request for %d msix vectors failed, err %d\n",
nvec, err);
goto err_release_regions;
}

AFAICS err can never be a positive value in that error path, but the

if (err < 0 || err != nvec)

check is confusing and should possibly be changed to:

if (err < 0)

/P