Commit 42b998d4 authored by Christian Marangi's avatar Christian Marangi Committed by Paolo Abeni

net: dsa: qca8k: fix NULL pointer dereference for of_device_get_match_data

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: 3bb0844e ("net: dsa: qca8k: cache match data to speed up access")
Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20220904215319.13070-1-ansuelsmth@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 686dc2db
...@@ -1889,9 +1889,9 @@ qca8k_sw_probe(struct mdio_device *mdiodev) ...@@ -1889,9 +1889,9 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->info = of_device_get_match_data(priv->dev);
priv->bus = mdiodev->bus; priv->bus = mdiodev->bus;
priv->dev = &mdiodev->dev; priv->dev = &mdiodev->dev;
priv->info = of_device_get_match_data(priv->dev);
priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset", priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
GPIOD_ASIS); GPIOD_ASIS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment