* [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 13:33 ` sashiko-bot
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, 1 reply; 19+ 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 related [flat|nested] 19+ messages in thread* Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data
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 13:33 ` sashiko-bot
2026-11-16 9:23 ` Uwe Kleine-König
0 siblings, 1 reply; 19+ messages in thread
From: sashiko-bot @ 2026-11-14 13:33 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-can, Oliver Hartkopp, Vincent Mailhol, Oleksij Rempel,
wsa+renesas
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] can: c_can: c_can_plat_probe() rejects c_can_id_table matches
with -ENODEV
--
commit e910ae3e03adb41c30f60d29d9b4c11824109fe5
Author: Marc Kleine-Budde <mkl@pengutronix.de>
can: c_can: c_can_plat_probe(): reject devices without match data
This commit rejects devices in c_can_plat_probe() when
device_get_match_data() returns NULL.
> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> index 75607b1afd2e9..b6012cd713cee 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;
[Severity: Medium]
Does this reject non-fwnode platform devices matched via c_can_id_table?
device_get_match_data() only queries dev_fwnode(dev) and never inspects
struct platform_driver.id_table. Because c_can_plat_driver registers
.id_table = c_can_id_table with .driver_data pointers, devices matched
through c_can_id_table get NULL from device_get_match_data() and fail
probe with -ENODEV unless platform_get_device_id(pdev) is checked as a
fallback (as done prior to 5e6c3454b405 ("net: can: Use
device_get_match_data()")).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=1
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data
2026-11-14 13:33 ` sashiko-bot
@ 2026-11-16 9:23 ` Uwe Kleine-König
2026-11-16 9:33 ` Marc Kleine-Budde
0 siblings, 1 reply; 19+ messages in thread
From: Uwe Kleine-König @ 2026-11-16 9:23 UTC (permalink / raw)
To: sashiko-reviews
Cc: Marc Kleine-Budde, linux-can, Oliver Hartkopp, Vincent Mailhol,
Oleksij Rempel, wsa+renesas
[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]
On Sat, Nov 14, 2026 at 01:33:34PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] can: c_can: c_can_plat_probe() rejects c_can_id_table matches
> with -ENODEV
> --
>
> commit e910ae3e03adb41c30f60d29d9b4c11824109fe5
> Author: Marc Kleine-Budde <mkl@pengutronix.de>
>
> can: c_can: c_can_plat_probe(): reject devices without match data
>
> This commit rejects devices in c_can_plat_probe() when
> device_get_match_data() returns NULL.
>
> > diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> > index 75607b1afd2e9..b6012cd713cee 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;
>
> [Severity: Medium]
> Does this reject non-fwnode platform devices matched via c_can_id_table?
It does, however there are none of these since commit 17b6e0280f31
("ARM: OMAP2+: Drop legacy platform data for am3 and am4 dcan") from
2019. So a useful followup cleanup is to drop c_can_id_table[].
For now I suggest to mention that in the commit log. (Though if there
was such a device, the patch would make the probe function return
-ENODEV instead of dying with a null-pointer exception, so it doesn't
break anything that worked before.)
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data
2026-11-16 9:23 ` Uwe Kleine-König
@ 2026-11-16 9:33 ` Marc Kleine-Budde
0 siblings, 0 replies; 19+ messages in thread
From: Marc Kleine-Budde @ 2026-11-16 9:33 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: sashiko-reviews, linux-can, Oliver Hartkopp, Vincent Mailhol,
Oleksij Rempel, wsa+renesas
[-- Attachment #1: Type: text/plain, Size: 2064 bytes --]
On 16.11.2026 10:23:02, Uwe Kleine-König wrote:
> On Sat, Nov 14, 2026 at 01:33:34PM +0000, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 1 potential
> > issue to consider:
> > - [Medium] can: c_can: c_can_plat_probe() rejects c_can_id_table matches
> > with -ENODEV
> > --
> >
> > commit e910ae3e03adb41c30f60d29d9b4c11824109fe5
> > Author: Marc Kleine-Budde <mkl@pengutronix.de>
> >
> > can: c_can: c_can_plat_probe(): reject devices without match data
> >
> > This commit rejects devices in c_can_plat_probe() when
> > device_get_match_data() returns NULL.
> >
> > > diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> > > index 75607b1afd2e9..b6012cd713cee 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;
> >
> > [Severity: Medium]
> > Does this reject non-fwnode platform devices matched via c_can_id_table?
>
> It does, however there are none of these since commit 17b6e0280f31
> ("ARM: OMAP2+: Drop legacy platform data for am3 and am4 dcan") from
> 2019. So a useful followup cleanup is to drop c_can_id_table[].
>
> For now I suggest to mention that in the commit log. (Though if there
> was such a device, the patch would make the probe function return
> -ENODEV instead of dying with a null-pointer exception, so it doesn't
> break anything that worked before.)
I'll drop this patch and remove the id_table from the driver instead.
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] 19+ 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-14 13:03 ` sashiko-bot
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, 2 replies; 19+ 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 related [flat|nested] 19+ 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-14 13:03 ` sashiko-bot
2026-11-16 9:14 ` Uwe Kleine-König
1 sibling, 0 replies; 19+ messages in thread
From: sashiko-bot @ 2026-11-14 13:03 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-can, Oliver Hartkopp, Vincent Mailhol, Oleksij Rempel,
wsa+renesas
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] can: flexcan: PM runtime double put in flexcan_probe() [1]
--
commit 358ff5ffd9961920463407d0074c445e652d7609
Author: Marc Kleine-Budde <mkl@pengutronix.de>
can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data
This commit restores falling back to platform_get_device_id() in
flexcan_probe() for non-OF devices and returns -ENODEV when no match data
is found.
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index 86b40abe9e767..2bb9e4184eb57 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 &
[Severity: Medium]
This problem wasn't introduced by this patch, but does flexcan_probe() drop
the PM runtime reference twice [1] when flexcan_setup_stop_mode()
fails?
flexcan_probe() acquires a reference with pm_runtime_get_noresume(), and
register_flexcandev() drops it with pm_runtime_put() before returning 0. If
flexcan_setup_stop_mode() then fails, the error path falls through from
failed_setup_stop_mode to failed_register and calls pm_runtime_put_noidle()
a second time, underflowing the usage counter:
drivers/net/can/flexcan/flexcan-core.c:flexcan_probe() {
...
err = register_flexcandev(dev);
if (err) {
dev_err(&pdev->dev, "registering netdev failed\n");
goto failed_register;
}
err = flexcan_setup_stop_mode(pdev);
if (err < 0) {
dev_err_probe(&pdev->dev, err, "setup stop mode failed\n");
goto failed_setup_stop_mode;
}
...
failed_setup_stop_mode:
unregister_flexcandev(dev);
failed_register:
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
}
[1] https://sashiko.dev/#/bug/linux-34c83ee1-4b00-422c-b485-f3256591cdcf
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=2
^ permalink raw reply [flat|nested] 19+ 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-14 13:03 ` sashiko-bot
@ 2026-11-16 9:14 ` Uwe Kleine-König
2026-11-16 9:32 ` Marc Kleine-Budde
1 sibling, 1 reply; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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 related [flat|nested] 19+ 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; 19+ 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] 19+ 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-14 13:03 ` sashiko-bot
2026-11-16 8:39 ` Biju Das
3 siblings, 2 replies; 19+ 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 related [flat|nested] 19+ 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-14 13:03 ` sashiko-bot
2026-11-14 13:09 ` Marc Kleine-Budde
2026-11-16 8:39 ` Biju Das
1 sibling, 1 reply; 19+ messages in thread
From: sashiko-bot @ 2026-11-14 13:03 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: linux-can, Oliver Hartkopp, Vincent Mailhol, Oleksij Rempel,
wsa+renesas
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] can: rcar_canfd: missing Fixes trailer in rcar_canfd_probe() fix
--
commit cdc806522e3e7626b43c3c2411bfae563ed95e04
Author: Marc Kleine-Budde <mkl@pengutronix.de>
> 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>
[Severity: Low]
Since commit ce7c5382758b ("can: rcar_canfd: rcar_canfd_probe: Add struct
rcar_canfd_hw_info to driver data") changed the match data from an enum
value to a struct rcar_canfd_hw_info pointer and dereferenced info
without checking for NULL, should this include a Fixes tag?
Fixes: ce7c5382758b ("can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data")
Also, rcar_canfd_probe() calls of_device_get_match_data() rather than
device_get_match_data().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=4
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data
2026-11-14 13:03 ` sashiko-bot
@ 2026-11-14 13:09 ` Marc Kleine-Budde
0 siblings, 0 replies; 19+ messages in thread
From: Marc Kleine-Budde @ 2026-11-14 13:09 UTC (permalink / raw)
To: sashiko-bot
Cc: linux-can, Oliver Hartkopp, Vincent Mailhol, Oleksij Rempel,
wsa+renesas
[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]
On 14.11.2026 13:03:20, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] can: rcar_canfd: missing Fixes trailer in rcar_canfd_probe() fix
> --
>
> commit cdc806522e3e7626b43c3c2411bfae563ed95e04
> Author: Marc Kleine-Budde <mkl@pengutronix.de>
>
> > 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>
>
> [Severity: Low]
> Since commit ce7c5382758b ("can: rcar_canfd: rcar_canfd_probe: Add struct
> rcar_canfd_hw_info to driver data") changed the match data from an enum
> value to a struct rcar_canfd_hw_info pointer and dereferenced info
> without checking for NULL, should this include a Fixes tag?
>
> Fixes: ce7c5382758b ("can: rcar_canfd: rcar_canfd_probe: Add struct rcar_canfd_hw_info to driver data")
>
> Also, rcar_canfd_probe() calls of_device_get_match_data() rather than
> device_get_match_data().
Will fix.
Marc
pw-bot: cr
--
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] 19+ 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-14 13:03 ` sashiko-bot
@ 2026-11-16 8:39 ` Biju Das
2026-11-16 8:54 ` Marc Kleine-Budde
1 sibling, 1 reply; 19+ 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@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org
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] 19+ 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; 19+ 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@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org
[-- 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] 19+ 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; 19+ 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@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org
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] 19+ 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; 19+ 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@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org
[-- 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] 19+ 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; 19+ 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@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org
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] 19+ messages in thread