[PATCH can 3/4] can: xilinx_can: xcan_probe(): reject devices without match data
Michal Simek
michal.simek at amd.com
Sun Nov 15 22:48:53 PST 2026
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 at 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 at amd.com>
Thanks,
Michal
More information about the linux-arm-kernel
mailing list