Skip to content

Commit c9d4b2c

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: check for errors on memory allocation of ports
Do not proceed probing if we couldn't allocate memory for the ports array, just error out. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a63ed92 commit c9d4b2c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,10 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
993993

994994
ocelot->ports = devm_kcalloc(&pdev->dev, ocelot->num_phys_ports,
995995
sizeof(struct ocelot_port *), GFP_KERNEL);
996+
if (!ocelot->ports) {
997+
err = -ENOMEM;
998+
goto out_put_ports;
999+
}
9961000

9971001
ocelot->vcap_is2_keys = vsc7514_vcap_is2_keys;
9981002
ocelot->vcap_is2_actions = vsc7514_vcap_is2_actions;

0 commit comments

Comments
 (0)