Commit 5027266d authored by Wei Fang's avatar Wei Fang Committed by Jakub Kicinski
Browse files

net: enetc: fix missing error code when pf->vf_state allocation fails



In enetc_pf_probe(), when the memory allocation for pf->vf_state fails,
the code jumps to the error handling label but the variable 'err' is not
assigned an appropriate error code beforehand. This causes the function
to return 0 (success) on an allocation failure path, misleading the
caller into thinking the probe succeeded. So set err to -ENOMEM before
jumping to the error handling label when the allocation for pf->vf_state
returns NULL.

Fixes: e15c5506 ("net: enetc: allocate vf_state during PF probes")
Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Reviewed-by: default avatarHarshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20260520064421.91569-3-wei.fang@nxp.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8c84c5ec
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -962,9 +962,11 @@ static int enetc_pf_probe(struct pci_dev *pdev,
	if (pf->total_vfs) {
		pf->vf_state = kzalloc_objs(struct enetc_vf_state,
					    pf->total_vfs);
		if (!pf->vf_state)
		if (!pf->vf_state) {
			err = -ENOMEM;
			goto err_alloc_vf_state;
		}
	}

	err = enetc_setup_mac_addresses(node, pf);
	if (err)