summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2020-09-18 03:07:26 +0200
committerDavid S. Miller <davem@davemloft.net>2020-09-18 22:52:33 +0200
commitc9d4b2cf16021d1f65e764f4035d7d1616e3bda3 (patch)
tree1dab92215d7f832d5afa9072c7d29943b28ff532 /drivers
parentnet: dsa: seville: fix buffer size of the queue system (diff)
downloadlinux-c9d4b2cf16021d1f65e764f4035d7d1616e3bda3.tar.xz
linux-c9d4b2cf16021d1f65e764f4035d7d1616e3bda3.zip
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mscc/ocelot_vsc7514.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index 65408bc994c4..904ea299a5e8 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -993,6 +993,10 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
ocelot->ports = devm_kcalloc(&pdev->dev, ocelot->num_phys_ports,
sizeof(struct ocelot_port *), GFP_KERNEL);
+ if (!ocelot->ports) {
+ err = -ENOMEM;
+ goto out_put_ports;
+ }
ocelot->vcap_is2_keys = vsc7514_vcap_is2_keys;
ocelot->vcap_is2_actions = vsc7514_vcap_is2_actions;