Re: [PATCH 2/3] bus: imx-weim: reject devices without match data
From: Frank Li
Date: Tue Oct 20 2026 - 12:10:57 EST
On Tue, Oct 20, 2026 at 05:36:34PM +0800, Jiale Yao wrote:
> Platform driver_override can bind a device to this driver without a
> matching OF entry. In that case, device_get_match_data() returns NULL
> and weim_parse_dt() dereferences it while configuring the controller.
>
> Reject devices without match data before parsing the device tree.
This should never happen, if run to here, driver data is always existed.
Frank
>
> Fixes: 85bf6d4e4b10 ("drivers: bus: add a new driver for WEIM")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
> ---
> drivers/bus/imx-weim.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
> index 87070155b057..3ecad0e453cc 100644
> --- a/drivers/bus/imx-weim.c
> +++ b/drivers/bus/imx-weim.c
> @@ -205,13 +205,17 @@ static int weim_timing_setup(struct device *dev, struct device_node *np,
>
> static int weim_parse_dt(struct platform_device *pdev)
> {
> - const struct imx_weim_devtype *devtype = device_get_match_data(&pdev->dev);
> + const struct imx_weim_devtype *devtype;
> int ret = 0, have_child = 0;
> struct device_node *child;
> struct weim_priv *priv;
> void __iomem *base;
> u32 reg;
>
> + devtype = device_get_match_data(&pdev->dev);
> + if (!devtype)
> + return -ENODATA;
> +
> if (devtype == &imx50_weim_devtype) {
> ret = imx_weim_gpr_setup(pdev);
> if (ret)
> --
> 2.34.1
>
>