Skip to contentSkip to conversation

can: fix probing and use of device_get_match_data()

PATCH In review Marc Kleine-Budde 6 participants 20 messages Nov 14 – Nov 16

Subsystems (5)
lore
Share & tools
lore

Marc Kleine-Budde

author maintainer
#0 lore raw

cover can: fix probing and use of device_get_match_data()

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.

---
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,

Signature · 1 line
Marc Kleine-Budde <[email protected]>
author maintainer
#1 lore raw

PATCH 1/4 can: c_can: c_can_plat_probe(): reject devices without match data

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()")
---
 drivers/net/can/c_can/c_can_platform.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/c_can/c_can_platform.c +2 -0
index 75607b1afd2e..b6012cd713ce 100644
@@ -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);
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data

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

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 <[email protected]>

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.

drivers/net/can/c_can/c_can_platform.c static int c_can_plat_probe(struct platform_device *pdev) · line 270

Quoted 10 lines
drivers/net/can/c_can/c_can_platform.c +2 -0
index 75607b1afd2e9..b6012cd713cee 100644
@@ -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()")).

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=1
#3 lore raw

Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data

Quoted 21 lines · On Sat, Nov 14, 2026 at 01:33:34PM +0000, [email protected] 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 <[email protected]>

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.

Quoted 7 lines
drivers/net/can/c_can/c_can_platform.c +0 -0
index 75607b1afd2e9..b6012cd713cee 100644
@@ -266,6 +266,8 @@ static int c_can_plat_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 
Quoted 6 lines

drivers/net/can/c_can/c_can_platform.c static int c_can_plat_probe(struct platform_device *pdev) · line 270

Quoted 3 lines
drivers/net/can/c_can/c_can_platform.c +2 -0
 	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

author maintainer
#4 lore raw

Re: [PATCH can 1/4] can: c_can: c_can_plat_probe(): reject devices without match data

Quoted 29 lines · Uwe Kleine-König
Quoted 21 lines · On Sat, Nov 14, 2026 at 01:33:34PM +0000, [email protected] 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 <[email protected]>

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.

Quoted 7 lines
drivers/net/can/c_can/c_can_platform.c +0 -0
index 75607b1afd2e9..b6012cd713cee 100644
@@ -266,6 +266,8 @@ static int c_can_plat_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 
Quoted 6 lines

drivers/net/can/c_can/c_can_platform.c static int c_can_plat_probe(struct platform_device *pdev) · line 270

Quoted 3 lines
drivers/net/can/c_can/c_can_platform.c +2 -0
 	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?

Quoted 8 lines

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

Signature · 4 lines
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   |
author maintainer
#5 lore raw

PATCH 2/4 can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data

In reply to Marc Kleine-Budde

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.

---
 drivers/net/can/flexcan/flexcan-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/can/flexcan/flexcan-core.c +5 -0
index 86b40abe9e76..2bb9e4184eb5 100644
@@ -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 &
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data

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…

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 <[email protected]>

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.

Quoted 6 lines
drivers/net/can/flexcan/flexcan-core.c +0 -0
index 86b40abe9e767..2bb9e4184eb57 100644
@@ -2148,6 +2148,11 @@ static int flexcan_probe(struct platform_device *pdev)
 		return PTR_ERR(regs);

drivers/net/can/flexcan/flexcan-core.c static int flexcan_probe(struct platform_device *pdev) · line 2158

Quoted 10 lines
drivers/net/can/flexcan/flexcan-core.c +5 -0
 
 	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

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=2
#7 lore raw

Re: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data

In reply to Marc Kleine-Budde

Hello Marc,

Quoted 30 lines · Marc Kleine-Budde

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.

---
 drivers/net/can/flexcan/flexcan-core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/can/flexcan/flexcan-core.c +0 -0
index 86b40abe9e76..2bb9e4184eb5 100644

drivers/net/can/flexcan/flexcan-core.c static int flexcan_probe(struct platform_device *pdev) · line 2155

Quoted 8 lines
drivers/net/can/flexcan/flexcan-core.c +5 -0
@@ -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

author maintainer
#8 lore raw

Re: [PATCH can 2/4] can: flexcan: flexcan_probe(): fix probing for m68k/coldfire and reject devices without match data

Quoted 11 lines · Uwe Kleine-König

drivers/net/can/flexcan/flexcan-core.c static int flexcan_probe(struct platform_device *pdev) · line 2155

Quoted 6 lines
drivers/net/can/flexcan/flexcan-core.c +5 -0
 	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.

Quoted 1 line

I'll work on this patch to hopefully get it into v7.5-rc1.

Thanks!

Quoted 3 lines

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

Signature · 4 lines
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   |
author maintainer
#9 lore raw

PATCH 3/4 can: xilinx_can: xcan_probe(): reject devices without match data

In reply to 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()")
---
 drivers/net/can/xilinx_can.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/xilinx_can.c +2 -0
index 43d7f22820b8..bbe6f9662cac 100644
@@ -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";
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 3/4
#10 lore raw

Re: [PATCH can 3/4] can: xilinx_can: xcan_probe(): reject devices without match data

Quoted 18 lines · 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()")
---
  drivers/net/can/xilinx_can.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/can/xilinx_can.c +0 -0
index 43d7f22820b8..bbe6f9662cac 100644

drivers/net/can/xilinx_can.c static int xcan_probe(struct platform_device *pdev) · line 1902

Quoted 8 lines
drivers/net/can/xilinx_can.c +2 -0
@@ -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";

Thanks,
Michal

author maintainer
#11 lore raw

PATCH 4/4 can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

In reply to 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.

---
 drivers/net/can/rcar/rcar_canfd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +2 -0
index 000a6433f46d..9d463a9c1766 100644
@@ -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 */
Signature · 1 line
2.53.0
#12 lore raw

Re: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

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

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 <[email protected]>

Quoted 9 lines

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.

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

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20261114-fix-device_get_match_data-v1-0-2d82025e9646@pengutronix.de?part=4
author maintainer
#13 lore raw

Re: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Quoted 24 lines · On 14.11.2026 13:03:20, [email protected] 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 <[email protected]>

Quoted 9 lines

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.

[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?

Quoted 4 lines
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

Signature · 4 lines
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   |
#14 lore raw

RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

In reply to Marc Kleine-Budde

Hi Marc,

Quoted 21 lines

-----Original Message-----
From: linux-arm-kernel <[email protected]> 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.

---
 drivers/net/can/rcar/rcar_canfd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +0 -0
index 000a6433f46d..9d463a9c1766 100644

drivers/net/can/rcar/rcar_canfd.c static int rcar_canfd_probe(struct platform_device *pdev) · line 2117

Quoted 5 lines
drivers/net/can/rcar/rcar_canfd.c +2 -0
@@ -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

Quoted 7 lines
drivers/net/can/rcar/rcar_canfd.c +0 -1
 	if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
 		fdmode = false;			/* Classical CAN only mode */
 
--

2.53.0

author maintainer
#15 lore raw

Re: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Quoted 34 lines · Biju Das

Hi Marc,

Quoted 21 lines

-----Original Message-----
From: linux-arm-kernel <[email protected]> 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.

---
 drivers/net/can/rcar/rcar_canfd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +0 -0
index 000a6433f46d..9d463a9c1766 100644

drivers/net/can/rcar/rcar_canfd.c static int rcar_canfd_probe(struct platform_device *pdev) · line 2117

Quoted 5 lines
drivers/net/can/rcar/rcar_canfd.c +2 -0
@@ -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

Quoted 1 line

[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

Signature · 4 lines
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   |
#16 lore raw

RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Hi Marc,

Quoted 46 lines

-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 16 November 2026 08:55
Subject: Re: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Quoted 39 lines · Biju Das

Hi Marc,

Quoted 26 lines

-----Original Message-----
From: linux-arm-kernel <[email protected]> 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.

---
 drivers/net/can/rcar/rcar_canfd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +0 -0
index 000a6433f46d..9d463a9c1766 100644

drivers/net/can/rcar/rcar_canfd.c static int rcar_canfd_probe(struct platform_device *pdev) · line 2117

Quoted 5 lines
drivers/net/can/rcar/rcar_canfd.c +2 -0
@@ -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

Quoted 8 lines
Quoted 3 lines

[1]
https://lore.kernel.org/all/0f7446324f6a0c8f0153d6532d92a6eeecd6a308.1
[email protected]/

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

author maintainer
#17 lore raw

Re: RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Quoted 11 lines · Biju Das
Quoted 4 lines

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.

Quoted 2 lines

in case someone wants to
test the driver using bus_override.

                        ^^^^^^^^^^^^

What's bus_override?

Marc

Signature · 4 lines
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   |
#18 lore raw

RE: RE: RE: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

Hi Marc,

Quoted 18 lines

-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
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

Quoted 2 lines · Biju Das
Quoted 2 lines

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.

Quoted 8 lines
Quoted 2 lines

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

Quoted 4 lines
Quoted 1 line

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.

Quoted 5 lines
Quoted 3 lines

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

#19 lore raw

Re: [PATCH can 4/4] can: rcar_canfd: rcar_canfd_probe(): reject devices without match data

In reply to Marc Kleine-Budde
Quoted 35 lines · Marc Kleine-Budde
Quoted 34 lines · Biju Das

Hi Marc,

Quoted 21 lines

-----Original Message-----
From: linux-arm-kernel <[email protected]> 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.

---
 drivers/net/can/rcar/rcar_canfd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/rcar/rcar_canfd.c +0 -0
index 000a6433f46d..9d463a9c1766 100644

drivers/net/can/rcar/rcar_canfd.c static int rcar_canfd_probe(struct platform_device *pdev) · line 2117

Quoted 5 lines
drivers/net/can/rcar/rcar_canfd.c +2 -0
@@ -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

Quoted 8 lines
Quoted 1 line

[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?

IMHO yes.

I just sent out a new revision of the change, find it at
https://lore.kernel.org/all/[email protected]/
as I failed to add you Cc.

Best regards
Uwe