Messages in this thread Patch in this message | | | From | Oleksij Rempel <> | Subject | [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference | Date | Thu, 29 Apr 2021 13:08:31 +0200 |
| |
Fix possible NULL pointer dereference in case devm_kzalloc() failed to allocate memory.
Fixes: 60a364760002 ("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> --- drivers/net/dsa/microchip/ksz8863_smi.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz8863_smi.c b/drivers/net/dsa/microchip/ksz8863_smi.c index 30d97ea7a949..9fb38e99001a 100644 --- a/drivers/net/dsa/microchip/ksz8863_smi.c +++ b/drivers/net/dsa/microchip/ksz8863_smi.c @@ -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); -- 2.29.2
| |