Skip to content

Commit

Permalink
net: dsa: ksz: ksz8795_spi_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: cc13e52 ("net: dsa: microchip: Add Microchip KSZ8863 SPI 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 d27f020 commit ba46b57
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/dsa/microchip/ksz8795_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ static int ksz8795_spi_probe(struct spi_device *spi)
int i, ret = 0;

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

ksz8->priv = spi;

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

0 comments on commit ba46b57

Please sign in to comment.