diff mbox series

[net-next,v1,1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference

Message ID 20210429110833.2181-1-o.rempel@pengutronix.de
State New
Headers show
Series [net-next,v1,1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference | expand

Commit Message

Oleksij Rempel April 29, 2021, 11:08 a.m. UTC
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(+)

Comments

Andrew Lunn April 29, 2021, 12:14 p.m. UTC | #1
On Thu, Apr 29, 2021 at 01:08:32PM +0200, Oleksij Rempel wrote:
> 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>

    Andrew
patchwork-bot+netdevbpf@kernel.org April 29, 2021, 11 p.m. UTC | #2
Hello:

This series was applied to netdev/net.git (refs/heads/master):

On Thu, 29 Apr 2021 13:08:31 +0200 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net-next,v1,1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
    https://git.kernel.org/netdev/net/c/d27f0201b93c
  - [net-next,v1,2/3] net: dsa: ksz: ksz8795_spi_probe: fix possible NULL pointer dereference
    https://git.kernel.org/netdev/net/c/ba46b576a795
  - [net-next,v1,3/3] net: dsa: ksz: ksz8863_smi_probe: set proper return value for ksz_switch_alloc()
    https://git.kernel.org/netdev/net/c/d4eecfb28b96

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

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);