net: dsa: ksz: ksz8795_spi_probe: fix possible NULL pointer dereference
Fix possible NULL pointer dereference in case devm_kzalloc() failed to
allocate memory
Fixes: cc13e52c3a
("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>
This commit is contained in:
Родитель
d27f0201b9
Коммит
ba46b576a7
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче