[PATCH net] can: flexcan: Fix probing for m68k/coldfire
From: Uwe Kleine-König (The Capable Hub)
Date: Thu Jun 18 2026 - 10:07:12 EST
When determining the device details was reworked in commit 5e6c3454b405
("net: can: Use device_get_match_data()") there was no replacement for
the previous handling of non-of instantiated devices via the device's
id_entry which then results in a NULL pointer exception. The only
in-tree provider of such a device is arch/m68k/coldfire/device.c.
Given the id_table only contains a single entry just hardcode the result
of `platform_get_device_id(pdev)->driver_data` and drop the unused
assignment to .driver_data from the table.
While touching the id table, drop the unusual comma after the terminator
entry.
Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx>
---
Hello,
this is essentially v2 of
https://lore.kernel.org/all/20260528094540.1867783-2-u.kleine-koenig@xxxxxxxxxxxx/,
but that patch was intended to be a cleanup, while the discussion then
revealed that there is a crash to be fixed.
Jean-Michel Hautbois confirmed (off-list) that Marc's and my suspicion
is true and probing the flexcan device provided by
arch/m68k/coldfire/device.c indeed crashes.
Best regards
Uwe
drivers/net/can/flexcan/flexcan-core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index f5d22c61503f..05b8ca72ca2a 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2077,10 +2077,9 @@ MODULE_DEVICE_TABLE(of, flexcan_of_match);
static const struct platform_device_id flexcan_id_table[] = {
{
.name = "flexcan-mcf5441x",
- .driver_data = (kernel_ulong_t)&fsl_mcf5441x_devtype_data,
}, {
/* sentinel */
- },
+ }
};
MODULE_DEVICE_TABLE(platform, flexcan_id_table);
@@ -2148,6 +2147,15 @@ static int flexcan_probe(struct platform_device *pdev)
return PTR_ERR(regs);
devtype_data = device_get_match_data(&pdev->dev);
+ if (!devtype_data)
+ /*
+ * If the device was instantiated via the traditional platform
+ * mechanisms (i.e. not by device tree), device_get_match_data()
+ * returns NULL. The only remaining such device is mcf_flexcan0
+ * (defined in arch/m68k/coldfire/device.c). Pick the right
+ * device type for that.
+ */
+ devtype_data = &fsl_mcf5441x_devtype_data;
if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
!((devtype_data->quirks &
base-commit: e2cae00c05d196491c318196792297f2dfbaa02c
--
2.47.3