Skip to content

Commit

Permalink
net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
Browse files Browse the repository at this point in the history
Fix possible NULL pointer dereference in case devm_kzalloc() failed to
allocate memory.

Fixes: 60a3647 ("net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Oleksij Rempel authored and David S. Miller committed Apr 29, 2021
1 parent 8343b1f commit d27f020
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/dsa/microchip/ksz8863_smi.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev)
int i;

ksz8 = devm_kzalloc(&mdiodev->dev, sizeof(struct ksz8), GFP_KERNEL);
if (!ksz8)
return -ENOMEM;

ksz8->priv = mdiodev;

dev = ksz_switch_alloc(&mdiodev->dev, ksz8);
Expand Down

0 comments on commit d27f020

Please sign in to comment.