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

* [PATCH net-next v1 2/3] net: dsa: ksz: ksz8795_spi_probe: fix possible NULL pointer dereference
  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 ` 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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 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: 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>
---
 drivers/net/dsa/microchip/ksz8795_spi.c | 3 +++
 1 file changed, 3 insertions(+)

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


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

* [PATCH net-next v1 3/3] net: dsa: ksz: ksz8863_smi_probe: set proper return value for ksz_switch_alloc()
  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 11:08 ` 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
  3 siblings, 1 reply; 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, kernel, netdev, linux-kernel, Russell King,
	Michael Grzeschik

ksz_switch_alloc() will return NULL only if allocation is failed. So,
the proper return value is -ENOMEM.

Fixes: 60a364760002 ("net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8863_smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/microchip/ksz8863_smi.c b/drivers/net/dsa/microchip/ksz8863_smi.c
index 9fb38e99001a..11293485138c 100644
--- a/drivers/net/dsa/microchip/ksz8863_smi.c
+++ b/drivers/net/dsa/microchip/ksz8863_smi.c
@@ -154,7 +154,7 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev)
 
 	dev = ksz_switch_alloc(&mdiodev->dev, ksz8);
 	if (!dev)
-		return -EINVAL;
+		return -ENOMEM;
 
 	for (i = 0; i < ARRAY_SIZE(ksz8863_regmap_config); i++) {
 		rc = ksz8863_regmap_config[i];
-- 
2.29.2


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

* Re: [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
  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 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 23:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2021-04-29 12:14 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Woojung Huh, UNGLinuxDriver, Florian Fainelli, Vivien Didelot,
	Vladimir Oltean, David S. Miller, Jakub Kicinski, Colin Ian King,
	kernel, netdev, linux-kernel, Russell King, Michael Grzeschik

On Thu, Apr 29, 2021 at 01:08:31PM +0200, Oleksij Rempel 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>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v1 2/3] net: dsa: ksz: ksz8795_spi_probe: fix possible NULL pointer dereference
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2021-04-29 12:14 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Woojung Huh, UNGLinuxDriver, Florian Fainelli, Vivien Didelot,
	Vladimir Oltean, David S. Miller, Jakub Kicinski, Colin Ian King,
	kernel, netdev, linux-kernel, Russell King, Michael Grzeschik

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


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

* Re: [PATCH net-next v1 3/3] net: dsa: ksz: ksz8863_smi_probe: set proper return value for ksz_switch_alloc()
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2021-04-29 12:14 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Woojung Huh, UNGLinuxDriver, Florian Fainelli, Vivien Didelot,
	Vladimir Oltean, David S. Miller, Jakub Kicinski, kernel, netdev,
	linux-kernel, Russell King, Michael Grzeschik

On Thu, Apr 29, 2021 at 01:08:33PM +0200, Oleksij Rempel wrote:
> ksz_switch_alloc() will return NULL only if allocation is failed. So,
> the proper return value is -ENOMEM.
> 
> Fixes: 60a364760002 ("net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference
  2021-04-29 11:08 [PATCH net-next v1 1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference Oleksij Rempel
                   ` (2 preceding siblings ...)
  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
  3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-29 23:00 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: woojung.huh, UNGLinuxDriver, andrew, f.fainelli, vivien.didelot,
	olteanv, davem, kuba, colin.king, kernel, netdev, linux-kernel,
	linux, m.grzeschik

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



^ permalink raw reply	[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.