diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2021-04-29 13:08:32 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-04-30 00:54:35 +0200 |
commit | ba46b576a7954fa54ff4c1ef976624794b6668f6 (patch) | |
tree | 4e16aa73127f594967c7dee39a5782bb139afc3f /drivers | |
parent | net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference (diff) | |
download | linux-ba46b576a7954fa54ff4c1ef976624794b6668f6.tar.xz linux-ba46b576a7954fa54ff4c1ef976624794b6668f6.zip |
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: cc13e52c3a89 ("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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/dsa/microchip/ksz8795_spi.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/dsa/microchip/ksz8795_spi.c b/drivers/net/dsa/microchip/ksz8795_spi.c index 85ba12aa82d8..ea7550d1b634 100644 --- a/drivers/net/dsa/microchip/ksz8795_spi.c +++ b/drivers/net/dsa/microchip/ksz8795_spi.c @@ -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); |