LF-14922 net: enetc: Fix null pointer accces in fsl-netc-prb-ierb driver probe

Fix NULL pointer access occurring when the 'netc-interfaces' property
is missing or not properly defined in DTS. The parsing function,
netc_prb_parse_if, expects to find "netc-interfaces" property
definition to allocate memory for pi->ifmode array.

Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
This commit is contained in:
Florin Leotescu 2025-02-07 14:39:57 +02:00
parent d8f7322db0
commit 86aad7676d

View File

@ -449,7 +449,7 @@ static int netc_prb_parse_if(struct netc_prb_ierb *pi, struct device *dev)
int ret, count;
count = of_property_count_u32_elems(node, "netc-interfaces");
if (count < 1)
if (count != 3)
return -EINVAL;
pi->ifmode = devm_kcalloc(dev, count, sizeof(pi->ifmode), GFP_KERNEL);
@ -535,7 +535,10 @@ static int netc_prb_ierb_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pi);
netc_prb_parse_if(pi, &pdev->dev);
err = netc_prb_parse_if(pi, &pdev->dev);
if (err)
goto disable_ipg_clk;
netc_netcmix_init(pdev);
err = netc_ierb_init(pdev);