netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
@ 2022-09-04 21:53 Christian Marangi
  2022-09-05 16:50 ` Vladimir Oltean
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christian Marangi @ 2022-09-04 21:53 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Christian Marangi, Russell King (Oracle), netdev, linux-kernel

of_device_get_match_data is called on priv->dev before priv->dev is
actually set. Move of_device_get_match_data after priv->dev is correctly
set to fix this kernel panic.

Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/dsa/qca/qca8k-8xxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 1d3e7782a71f..c181346388a4 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -1889,9 +1889,9 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->info = of_device_get_match_data(priv->dev);
 	priv->bus = mdiodev->bus;
 	priv->dev = &mdiodev->dev;
+	priv->info = of_device_get_match_data(priv->dev);
 
 	priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
 						   GPIOD_ASIS);
-- 
2.37.2


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

* Re: [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
  2022-09-04 21:53 [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data Christian Marangi
@ 2022-09-05 16:50 ` Vladimir Oltean
  2022-09-05 16:59   ` Christian Marangi
  2022-09-05 17:10 ` Vladimir Oltean
  2022-09-06  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Vladimir Oltean @ 2022-09-05 16:50 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Russell King (Oracle),
	netdev, linux-kernel

On Sun, Sep 04, 2022 at 11:53:19PM +0200, Christian Marangi wrote:
> of_device_get_match_data is called on priv->dev before priv->dev is
> actually set. Move of_device_get_match_data after priv->dev is correctly
> set to fix this kernel panic.
> 
> Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---

Did this ever work? Was it tested when you sent the big refactoring
patch set?

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

* Re: [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
  2022-09-05 16:50 ` Vladimir Oltean
@ 2022-09-05 16:59   ` Christian Marangi
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Marangi @ 2022-09-05 16:59 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Russell King (Oracle),
	netdev, linux-kernel

On Mon, Sep 05, 2022 at 07:50:39PM +0300, Vladimir Oltean wrote:
> On Sun, Sep 04, 2022 at 11:53:19PM +0200, Christian Marangi wrote:
> > of_device_get_match_data is called on priv->dev before priv->dev is
> > actually set. Move of_device_get_match_data after priv->dev is correctly
> > set to fix this kernel panic.
> > 
> > Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > ---
> 
> Did this ever work? Was it tested when you sent the big refactoring
> patch set?

I have to be honest here. I feel really embarrassed about this.
The short story is that the refactor was tested on Openwrt with 5.15 by
manually applying the changes. This fix was applied there but I forgot
to put it in the final series.

I notice this mistake only now that I'm backporting patches and the
manually applied fix was reset.

Again I'm really sorry.

-- 
	Ansuel

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

* Re: [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
  2022-09-04 21:53 [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data Christian Marangi
  2022-09-05 16:50 ` Vladimir Oltean
@ 2022-09-05 17:10 ` Vladimir Oltean
  2022-09-06  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Vladimir Oltean @ 2022-09-05 17:10 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Russell King (Oracle),
	netdev, linux-kernel

On Sun, Sep 04, 2022 at 11:53:19PM +0200, Christian Marangi wrote:
> of_device_get_match_data is called on priv->dev before priv->dev is
> actually set. Move of_device_get_match_data after priv->dev is correctly
> set to fix this kernel panic.
> 
> Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

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

* Re: [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
  2022-09-04 21:53 [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data Christian Marangi
  2022-09-05 16:50 ` Vladimir Oltean
  2022-09-05 17:10 ` Vladimir Oltean
@ 2022-09-06  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-06  9:40 UTC (permalink / raw)
  To: Christian Marangi
  Cc: andrew, vivien.didelot, f.fainelli, olteanv, davem, edumazet,
	kuba, pabeni, rmk+kernel, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Sun,  4 Sep 2022 23:53:19 +0200 you wrote:
> of_device_get_match_data is called on priv->dev before priv->dev is
> actually set. Move of_device_get_match_data after priv->dev is correctly
> set to fix this kernel panic.
> 
> Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data
    https://git.kernel.org/netdev/net/c/42b998d4aa59

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] 5+ messages in thread

end of thread, other threads:[~2022-09-06  9:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-04 21:53 [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data Christian Marangi
2022-09-05 16:50 ` Vladimir Oltean
2022-09-05 16:59   ` Christian Marangi
2022-09-05 17:10 ` Vladimir Oltean
2022-09-06  9:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).