From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Vincent Mailhol <mailhol@kernel.org>,
Rob Herring <robh@kernel.org>, Harini T <harini.t@amd.com>,
Michal Simek <michal.simek@amd.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>
Cc: kernel@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
stable@vger.kernel.org,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Subject: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
Date: Sat, 14 Nov 2026 13:56:15 +0100 [thread overview]
Message-ID: <20261114-fix-device_get_match_data-v1-2-2d82025e9646@pengutronix.de> (raw)
In-Reply-To: <20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de>
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.
Restore retrieving the devtype_data via platform_get_device_id().
Also a device bound through driver_override need not match an entry in
of_match_table or id_table. In that case device_get_match_data() returns
NULL, but flexcan_probe() dereferences the result.
Reject devices without match data before continuing probe.
Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
Cc: stable@vger.kernel.org
Reported-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Closes: https://lore.kernel.org/all/20260618140147.142489-2-u.kleine-koenig@baylibre.com/
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Closes: https://lore.kernel.org/all/20260528-fluorescent-sage-ladybug-43261b-mkl@pengutronix.de/
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/flexcan/flexcan-core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 86b40abe9e76..2bb9e4184eb5 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2148,6 +2148,11 @@ static int flexcan_probe(struct platform_device *pdev)
return PTR_ERR(regs);
devtype_data = device_get_match_data(&pdev->dev);
+ if (!devtype_data && platform_get_device_id(pdev))
+ devtype_data = (struct flexcan_devtype_data *)
+ platform_get_device_id(pdev)->driver_data;
+ if (!devtype_data)
+ return -ENODEV;
if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
!((devtype_data->quirks &
--
2.53.0
next prev parent reply other threads:[~2026-11-14 12:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 12:56 [PATCH can 0/4] can: fix probing and use of device_get_match_data() Marc Kleine-Budde
2026-11-14 12:56 ` [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data Marc Kleine-Budde
2026-11-14 12:56 ` Marc Kleine-Budde [this message]
2026-11-14 12:56 ` [PATCH can 3/4] can: xilinx_can: xcan_probe(): " Marc Kleine-Budde
2026-11-14 12:56 ` [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): " Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261114-fix-device_get_match_data-v1-2-2d82025e9646@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=geert+renesas@glider.be \
--cc=harini.t@amd.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mailhol@kernel.org \
--cc=michal.simek@amd.com \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®