* [PATCH can 0/4] can: fix probing and use of device_get_match_data()
@ 2026-11-14 12:56 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
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 12:56 UTC (permalink / raw)
To: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel,
linux-renesas-soc, Marc Kleine-Budde, stable,
Uwe Kleine-König
With patch 5e6c3454b405 ("net: can: Use device_get_match_data()") several
CAN drivers were converted to device_get_match_data(). The author assumed
that error checking for matching and match data is not necessary.
This misses the fact that that drivers on the platform bus can forcefully
bound using driver_override and device_get_match_data() will return NULL.
By using device_get_match_data(), this change broke probing for
m68k/coldfire, which still uses platform devices.
This series adds missing NULL pointer checks and fixes probing for the
flexcan on m68k/coldfire.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Marc Kleine-Budde (4):
can: c_can: c_can_plat_probe(): reject devices without match data
can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
can: xilinx_can: xcan_probe(): reject devices without match data
can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
drivers/net/can/c_can/c_can_platform.c | 2 ++
drivers/net/can/flexcan/flexcan-core.c | 5 +++++
drivers/net/can/rcar/rcar_canfd.c | 2 ++
drivers/net/can/xilinx_can.c | 2 ++
4 files changed, 11 insertions(+)
---
base-commit: ead6fa9a0ab194f02a2f36d634b193e9c5f9a1c6
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main
change-id: 20261114-fix-device_get_match_data-11dc9cd85ec7
Best regards,
--
Marc Kleine-Budde <mkl@pengutronix.de>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data
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 ` Marc Kleine-Budde
2026-11-14 12:56 ` [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and " Marc Kleine-Budde
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 12:56 UTC (permalink / raw)
To: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel,
linux-renesas-soc, Marc Kleine-Budde
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 c_can_plat_probe() dereferences the result.
Reject devices without match data before continuing probe.
Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/c_can/c_can_platform.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 75607b1afd2e..b6012cd713ce 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -266,6 +266,8 @@ static int c_can_plat_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
drvdata = device_get_match_data(&pdev->dev);
+ if (!drvdata)
+ return -ENODEV;
/* get the appropriate clk */
clk = devm_clk_get(&pdev->dev, NULL);
--
2.53.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
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
2026-11-16 9:14 ` Uwe Kleine-König
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
3 siblings, 1 reply; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 12:56 UTC (permalink / raw)
To: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel,
linux-renesas-soc, Marc Kleine-Budde, stable,
Uwe Kleine-König
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH can 3/4] can: xilinx_can: xcan_probe(): reject devices without match data
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 ` [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and " Marc Kleine-Budde
@ 2026-11-14 12:56 ` Marc Kleine-Budde
2026-11-16 6:48 ` Michal Simek
2026-11-14 12:56 ` [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): " Marc Kleine-Budde
3 siblings, 1 reply; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 12:56 UTC (permalink / raw)
To: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel,
linux-renesas-soc, Marc Kleine-Budde
A device bound through driver_override need not match an entry in
of_match_table. In that case device_get_match_data() returns NULL, but
xcan_probe() dereferences the result.
Reject devices without match data before continuing probe.
Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/xilinx_can.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 43d7f22820b8..bbe6f9662cac 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -1895,6 +1895,8 @@ static int xcan_probe(struct platform_device *pdev)
}
devtype = device_get_match_data(&pdev->dev);
+ if (!devtype)
+ return -ENODEV;
hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
"tx-mailbox-count" : "tx-fifo-depth";
--
2.53.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-14 12:56 [PATCH can 0/4] can: fix probing and use of device_get_match_data() Marc Kleine-Budde
` (2 preceding siblings ...)
2026-11-14 12:56 ` [PATCH can 3/4] can: xilinx_can: xcan_probe(): " Marc Kleine-Budde
@ 2026-11-14 12:56 ` Marc Kleine-Budde
2026-11-16 8:39 ` Biju Das
3 siblings, 1 reply; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 12:56 UTC (permalink / raw)
To: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel,
linux-renesas-soc, Marc Kleine-Budde
A device bound through driver_override need not match an entry in
of_match_table. In that case device_get_match_data() returns NULL, but
rcar_canfd_probe() dereferences the result.
Reject devices without match data before continuing probe.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/rcar/rcar_canfd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 000a6433f46d..9d463a9c1766 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -2113,6 +2113,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
int i;
info = of_device_get_match_data(dev);
+ if (!info)
+ return -ENODEV;
if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
fdmode = false; /* Classical CAN only mode */
--
2.53.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH can 3/4] can: xilinx_can: xcan_probe(): reject devices without match data
2026-11-14 12:56 ` [PATCH can 3/4] can: xilinx_can: xcan_probe(): " Marc Kleine-Budde
@ 2026-11-16 6:48 ` Michal Simek
0 siblings, 0 replies; 13+ messages in thread
From: Michal Simek @ 2026-11-16 6:48 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol, Rob Herring, Harini T,
Geert Uytterhoeven, Magnus Damm
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
On 11/14/26 13:56, Marc Kleine-Budde wrote:
> A device bound through driver_override need not match an entry in
> of_match_table. In that case device_get_match_data() returns NULL, but
> xcan_probe() dereferences the result.
>
> Reject devices without match data before continuing probe.
>
> Fixes: 5e6c3454b405 ("net: can: Use device_get_match_data()")
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> drivers/net/can/xilinx_can.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
> index 43d7f22820b8..bbe6f9662cac 100644
> --- a/drivers/net/can/xilinx_can.c
> +++ b/drivers/net/can/xilinx_can.c
> @@ -1895,6 +1895,8 @@ static int xcan_probe(struct platform_device *pdev)
> }
>
> devtype = device_get_match_data(&pdev->dev);
> + if (!devtype)
> + return -ENODEV;
>
> hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
> "tx-mailbox-count" : "tx-fifo-depth";
>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Thanks,
Michal
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-14 12:56 ` [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): " Marc Kleine-Budde
@ 2026-11-16 8:39 ` Biju Das
2026-11-16 8:54 ` Marc Kleine-Budde
0 siblings, 1 reply; 13+ messages in thread
From: Biju Das @ 2026-11-16 8:39 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol, Rob Herring, Harini T,
Michal Simek, Geert Uytterhoeven, magnus.damm,
Uwe Kleine-König
Cc: kernel, linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
Hi Marc,
> -----Original Message-----
> From: linux-arm-kernel <linux-arm-kernel-bounces@lists.infradead.org> On Behalf Of Marc Kleine-Budde
> Sent: 14 November 2026 12:56
> Subject: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
>
> A device bound through driver_override need not match an entry in of_match_table. In that case
> device_get_match_data() returns NULL, but
> rcar_canfd_probe() dereferences the result.
>
> Reject devices without match data before continuing probe.
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> drivers/net/can/rcar/rcar_canfd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index 000a6433f46d..9d463a9c1766 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
> @@ -2113,6 +2113,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
> int i;
>
> info = of_device_get_match_data(dev);
> + if (!info)
> + return -ENODEV;
There is a patch on the fly to disable driver_override by default [1].
In that case if we plan to use driver_override, probe will return failure.
I may be wrong. Please correct me if Iam wrong
[1] https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1790612298.git.u.kleine-koenig@baylibre.com/
Cheers,
Biju
>
> if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
> fdmode = false; /* Classical CAN only mode */
>
> --
> 2.53.0
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-16 8:39 ` Biju Das
@ 2026-11-16 8:54 ` Marc Kleine-Budde
2026-11-16 9:12 ` Biju Das
0 siblings, 1 reply; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-16 8:54 UTC (permalink / raw)
To: Biju Das
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, magnus.damm, Uwe Kleine-König, kernel,
linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 2054 bytes --]
On 16.11.2026 08:39:36, Biju Das wrote:
> Hi Marc,
>
> > -----Original Message-----
> > From: linux-arm-kernel <linux-arm-kernel-bounces@lists.infradead.org> On Behalf Of Marc Kleine-Budde
> > Sent: 14 November 2026 12:56
> > Subject: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
> >
> > A device bound through driver_override need not match an entry in of_match_table. In that case
> > device_get_match_data() returns NULL, but
> > rcar_canfd_probe() dereferences the result.
> >
> > Reject devices without match data before continuing probe.
> >
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > ---
> > drivers/net/can/rcar/rcar_canfd.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> > index 000a6433f46d..9d463a9c1766 100644
> > --- a/drivers/net/can/rcar/rcar_canfd.c
> > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > @@ -2113,6 +2113,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
> > int i;
> >
> > info = of_device_get_match_data(dev);
> > + if (!info)
> > + return -ENODEV;
>
>
> There is a patch on the fly to disable driver_override by default [1].
> In that case if we plan to use driver_override, probe will return failure.
> I may be wrong. Please correct me if Iam wrong
>
> [1] https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1790612298.git.u.kleine-koenig@baylibre.com/
Thanks, I wasn't aware of this series. I tested the driver_override on
the flexcan driver with latest net/main, fixed it, and applied the fix
to all affected CAN drivers.
Should I drop the driver_override related null pointer checks from this
series?
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-16 8:54 ` Marc Kleine-Budde
@ 2026-11-16 9:12 ` Biju Das
2026-11-16 9:20 ` Marc Kleine-Budde
0 siblings, 1 reply; 13+ messages in thread
From: Biju Das @ 2026-11-16 9:12 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, magnus.damm, Uwe Kleine-König, kernel,
linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
Hi Marc,
> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 16 November 2026 08:55
> Subject: Re: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match
> data
>
> On 16.11.2026 08:39:36, Biju Das wrote:
> > Hi Marc,
> >
> > > -----Original Message-----
> > > From: linux-arm-kernel
> > > <linux-arm-kernel-bounces@lists.infradead.org> On Behalf Of Marc
> > > Kleine-Budde
> > > Sent: 14 November 2026 12:56
> > > Subject: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject
> > > devices without match data
> > >
> > > A device bound through driver_override need not match an entry in
> > > of_match_table. In that case
> > > device_get_match_data() returns NULL, but
> > > rcar_canfd_probe() dereferences the result.
> > >
> > > Reject devices without match data before continuing probe.
> > >
> > > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > > ---
> > > drivers/net/can/rcar/rcar_canfd.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/net/can/rcar/rcar_canfd.c
> > > b/drivers/net/can/rcar/rcar_canfd.c
> > > index 000a6433f46d..9d463a9c1766 100644
> > > --- a/drivers/net/can/rcar/rcar_canfd.c
> > > +++ b/drivers/net/can/rcar/rcar_canfd.c
> > > @@ -2113,6 +2113,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
> > > int i;
> > >
> > > info = of_device_get_match_data(dev);
> > > + if (!info)
> > > + return -ENODEV;
> >
> >
> > There is a patch on the fly to disable driver_override by default [1].
> > In that case if we plan to use driver_override, probe will return failure.
> > I may be wrong. Please correct me if Iam wrong
> >
> > [1]
> > https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1
> > 790612298.git.u.kleine-koenig@baylibre.com/
>
> Thanks, I wasn't aware of this series. I tested the driver_override on the flexcan driver with latest
> net/main, fixed it, and applied the fix to all affected CAN drivers.
>
> Should I drop the driver_override related null pointer checks from this series?
I think so, currently only few drivers are using driver_override feature and
majority don't. There is a work in progress to disable this feature by
default. The driver needs driver_override will adjust the probe() to make it
functional, so it won't fail at all in probe().
But here we are making probe to fail, in case someone wants to
test the driver using bus_override.
Cheers,
Biju
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
2026-11-14 12:56 ` [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and " Marc Kleine-Budde
@ 2026-11-16 9:14 ` Uwe Kleine-König
2026-11-16 9:32 ` Marc Kleine-Budde
0 siblings, 1 reply; 13+ messages in thread
From: Uwe Kleine-König @ 2026-11-16 9:14 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm, kernel, linux-can, linux-kernel,
linux-arm-kernel, linux-renesas-soc, stable
[-- Attachment #1: Type: text/plain, Size: 2499 bytes --]
Hello Marc,
On Sat, Nov 14, 2026 at 01:56:15PM +0100, Marc Kleine-Budde wrote:
> 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;
My stance is that the ability to bind an "unexpected" device via
driver_override is something that should be handled in the core, see
https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1790612298.git.u.kleine-koenig@baylibre.com/
for the latest patch to address this. I'll work on this patch to
hopefully get it into v7.5-rc1. IMHO it's ok to not fix this in a driver
specific way now. (And then my patch referenced above in the first
Closes:-trailer is IMHO better than this patch.)
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-16 9:12 ` Biju Das
@ 2026-11-16 9:20 ` Marc Kleine-Budde
2026-11-16 9:27 ` Biju Das
0 siblings, 1 reply; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-16 9:20 UTC (permalink / raw)
To: Biju Das
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, magnus.damm, Uwe Kleine-König, kernel,
linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]
On 16.11.2026 09:12:13, Biju Das wrote:
> > Thanks, I wasn't aware of this series. I tested the driver_override on the flexcan driver with latest
> > net/main, fixed it, and applied the fix to all affected CAN drivers.
> >
> > Should I drop the driver_override related null pointer checks from this series?
>
> I think so, currently only few drivers are using driver_override feature and
> majority don't. There is a work in progress to disable this feature by
> default. The driver needs driver_override will adjust the probe() to make it
> functional, so it won't fail at all in probe().
>
> But here we are making probe to fail,
Without my patch, using driver_override the info pointer is NULL and it
will crash 5 lines later with a NULL pointer dereference.
> in case someone wants to
> test the driver using bus_override.
^^^^^^^^^^^^
What's bus_override?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-16 9:20 ` Marc Kleine-Budde
@ 2026-11-16 9:27 ` Biju Das
0 siblings, 0 replies; 13+ messages in thread
From: Biju Das @ 2026-11-16 9:27 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, magnus.damm, Uwe Kleine-König, kernel,
linux-can, linux-kernel, linux-arm-kernel, linux-renesas-soc
Hi Marc,
> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 16 November 2026 09:20
> Subject: Re: RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match
> data
>
> On 16.11.2026 09:12:13, Biju Das wrote:
> > > Thanks, I wasn't aware of this series. I tested the driver_override
> > > on the flexcan driver with latest net/main, fixed it, and applied the fix to all affected CAN
> drivers.
> > >
> > > Should I drop the driver_override related null pointer checks from this series?
> >
> > I think so, currently only few drivers are using driver_override
> > feature and majority don't. There is a work in progress to disable
> > this feature by default. The driver needs driver_override will adjust
> > the probe() to make it functional, so it won't fail at all in probe().
> >
> > But here we are making probe to fail,
>
> Without my patch, using driver_override the info pointer is NULL and it will crash 5 lines later with
> a NULL pointer dereference.
If someone wants to test non-functional driver_override in a driver,
then it’s OK, I guess, at the expense of some code memory.
>
> > in case someone wants to
> > test the driver using bus_override.
> ^^^^^^^^^^^^
> What's bus_override?
Sorry it is a typo, I meant driver_override.
Cheers,
Biju
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
2026-11-16 9:14 ` Uwe Kleine-König
@ 2026-11-16 9:32 ` Marc Kleine-Budde
0 siblings, 0 replies; 13+ messages in thread
From: Marc Kleine-Budde @ 2026-11-16 9:32 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Vincent Mailhol, Rob Herring, Harini T, Michal Simek,
Geert Uytterhoeven, Magnus Damm, kernel, linux-can, linux-kernel,
linux-arm-kernel, linux-renesas-soc, stable
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]
On 16.11.2026 10:14:17, Uwe Kleine-König wrote:
> > 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;
>
> My stance is that the ability to bind an "unexpected" device via
> driver_override is something that should be handled in the core, see
> https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1790612298.git.u.kleine-koenig@baylibre.com/
> for the latest patch to address this.
Thanks, Biju Das already pointed out that series.
> I'll work on this patch to hopefully get it into v7.5-rc1.
Thanks!
> IMHO it's ok to not fix this in a driver specific way now. (And then
> my patch referenced above in the first Closes:-trailer is IMHO better
> than this patch.)
I'll drop the other patches, that only fix the driver_override case.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-11-16 9:32 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and " Marc Kleine-Budde
2026-11-16 9:14 ` Uwe Kleine-König
2026-11-16 9:32 ` Marc Kleine-Budde
2026-11-14 12:56 ` [PATCH can 3/4] can: xilinx_can: xcan_probe(): " Marc Kleine-Budde
2026-11-16 6:48 ` Michal Simek
2026-11-14 12:56 ` [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): " Marc Kleine-Budde
2026-11-16 8:39 ` Biju Das
2026-11-16 8:54 ` Marc Kleine-Budde
2026-11-16 9:12 ` Biju Das
2026-11-16 9:20 ` Marc Kleine-Budde
2026-11-16 9:27 ` Biju Das
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®