[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231204154315.3906267-1-dd@embedd.com>
Date: Mon, 4 Dec 2023 16:43:15 +0100
From: Daniel Danzberger <dd@...edd.com>
To: woojung.huh@...rochip.com,
UNGLinuxDriver@...rochip.com
Cc: netdev@...r.kernel.org,
Daniel Danzberger <dd@...edd.com>
Subject: [PATCH] net: dsa: microchip: fix NULL pointer dereference on platform init
Fixes a NULL pointer access when registering a switch device that has
not been defined via DTS.
This might happen when the switch is used on a platform like x86 that
doesn't use DTS and instantiates devices in platform specific init code.
Signed-off-by: Daniel Danzberger <dd@...edd.com>
---
drivers/net/dsa/microchip/ksz_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 9545aed905f5..525e13d9e39c 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1678,7 +1678,7 @@ static int ksz_check_device_id(struct ksz_device *dev)
dt_chip_data = of_device_get_match_data(dev->dev);
/* Check for Device Tree and Chip ID */
- if (dt_chip_data->chip_id != dev->chip_id) {
+ if (dt_chip_data && dt_chip_data->chip_id != dev->chip_id) {
dev_err(dev->dev,
"Device tree specifies chip %s but found %s, please fix it!\n",
dt_chip_data->dev_name, dev->info->dev_name);
--
2.39.2
Powered by blists - more mailing lists