netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dsa: microchip: fix NULL pointer dereference on platform init
@ 2023-12-04 15:43 Daniel Danzberger
  2023-12-04 17:43 ` Vladimir Oltean
  2023-12-05 10:12 ` Vladimir Oltean
  0 siblings, 2 replies; 17+ messages in thread
From: Daniel Danzberger @ 2023-12-04 15:43 UTC (permalink / raw)
  To: woojung.huh, UNGLinuxDriver; +Cc: netdev, Daniel Danzberger

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@embedd.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


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

end of thread, other threads:[~2023-12-06 21:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 15:43 [PATCH] net: dsa: microchip: fix NULL pointer dereference on platform init Daniel Danzberger
2023-12-04 17:43 ` Vladimir Oltean
2023-12-05  8:00   ` Daniel Danzberger
2023-12-05  8:36     ` Vladimir Oltean
2023-12-05  9:08       ` Daniel Danzberger
2023-12-05  9:39         ` Vladimir Oltean
2023-12-05 16:55     ` Vladimir Oltean
2023-12-05 17:33       ` Daniel Danzberger
2023-12-05 18:17         ` Vladimir Oltean
2023-12-05 22:15           ` Daniel Danzberger
2023-12-06  0:37             ` Vladimir Oltean
2023-12-06 15:26               ` Andrew Lunn
2023-12-06 21:49                 ` Vladimir Oltean
2023-12-05 10:12 ` Vladimir Oltean
2023-12-05 11:44   ` Daniel Danzberger
2023-12-05 12:04     ` Vladimir Oltean
2023-12-05 12:42       ` Vladimir Oltean

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).