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

Marc Kleine-Budde mkl at pengutronix.de
Sat Nov 14 04:56:14 PST 2026


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




More information about the linux-arm-kernel mailing list