0cca2788f6d3f5183f2f82f817099b3bbd698361
[openwrt/staging/blogic.git] /
1 From 057bcf15db8e625276ddf02b2b7c668a3cb43f81 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sun, 4 Sep 2022 23:46:24 +0200
4 Subject: [net PATCH] net: dsa: qca8k: fix NULL pointer dereference for
5 of_device_get_match_data
6
7 of_device_get_match_data is called on priv->dev before priv->dev is
8 actually set. Move of_device_get_match_data after priv->dev is correctly
9 set to fix this kernel panic.
10
11 Fixes: 3bb0844e7bcd ("net: dsa: qca8k: cache match data to speed up access")
12 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
13 ---
14 drivers/net/dsa/qca/qca8k-8xxx.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17 --- a/drivers/net/dsa/qca/qca8k-8xxx.c
18 +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
19 @@ -1835,9 +1835,9 @@ qca8k_sw_probe(struct mdio_device *mdiod
20 if (!priv)
21 return -ENOMEM;
22
23 - priv->info = of_device_get_match_data(priv->dev);
24 priv->bus = mdiodev->bus;
25 priv->dev = &mdiodev->dev;
26 + priv->info = of_device_get_match_data(priv->dev);
27
28 priv->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
29 GPIOD_ASIS);