Skip to content

Commit 5027266

Browse files
WeiFang-NXPkuba-moo
authored andcommitted
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: e15c550 ("net: enetc: allocate vf_state during PF probes") Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com> Link: https://patch.msgid.link/20260520064421.91569-3-wei.fang@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8c84c5e commit 5027266

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/net/ethernet/freescale/enetc/enetc_pf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
962962
if (pf->total_vfs) {
963963
pf->vf_state = kzalloc_objs(struct enetc_vf_state,
964964
pf->total_vfs);
965-
if (!pf->vf_state)
965+
if (!pf->vf_state) {
966+
err = -ENOMEM;
966967
goto err_alloc_vf_state;
968+
}
967969
}
968970

969971
err = enetc_setup_mac_addresses(node, pf);

0 commit comments

Comments
 (0)