All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
@ 2021-04-29 11:08 Oleksij Rempel
  2021-04-29 11:08 ` [PATCH net-next v1 2/3] net: dsa: ksz: ksz8795_spi_probe: " Oleksij Rempel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Oleksij Rempel @ 2021-04-29 11:08 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Florian Fainelli,
	Vivien Didelot, Vladimir Oltean, David S. Miller, Jakub Kicinski
  Cc: Oleksij Rempel, Colin Ian King, kernel, netdev, linux-kernel,
	Russell King, Michael Grzeschik

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-29 23:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 11:08 [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference Oleksij Rempel
2021-04-29 11:08 ` [PATCH net-next v1 2/3] net: dsa: ksz: ksz8795_spi_probe: " Oleksij Rempel
2021-04-29 12:14   ` Andrew Lunn
2021-04-29 11:08 ` [PATCH net-next v1 3/3] net: dsa: ksz: ksz8863_smi_probe: set proper return value for ksz_switch_alloc() Oleksij Rempel
2021-04-29 12:14   ` Andrew Lunn
2021-04-29 12:14 ` [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference Andrew Lunn
2021-04-29 23:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.