]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
authorOleksij Rempel <o.rempel@pengutronix.de>
Thu, 29 Apr 2021 11:08:31 +0000 (13:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Apr 2021 22:54:35 +0000 (15:54 -0700)
Fix possible NULL pointer dereference in case devm_kzalloc() failed to
allocate memory.

Fixes: 2555630ed86f ("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>
drivers/net/dsa/microchip/ksz8863_smi.c

index 30d97ea7a949c1df0b734cffdfc397022d8184cf..9fb38e99001a43941b4e5a53366af9d8530ef3d3 100644 (file)
@@ -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);