In gud_probe(), evaluating drm->mode_config.min_width before drmm_mode_config_init() and before assigning fields from the display descriptor causes the check to evaluate against 0, returning -EINVAL and unconditionally failing driver probe on non-DMA USB display devices. Move the display descriptor min/max width and height validation to after drmm_mode_config_init() and field assignments. Tested in QEMU against Linux 7.3.0-rc3 with a non-DMA USB GUD display device: on the unfixed kernel gud_probe() evaluates zero-initialized drm->mode_config fields before drmm_mode_config_init() and returns -EINVAL (failing device initialization); whereas with this fix applied, gud_probe() validates descriptor min/max bounds after initialization, allowing the driver to probe cleanly. Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Hui Peng --- drivers/gpu/drm/gud/gud_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c index 3a1b9e2a2eaa..f7826e3d849f 100644 --- a/drivers/gpu/drm/gud/gud_drv.c +++ b/drivers/gpu/drm/gud/gud_drv.c @@ -506,6 +506,12 @@ static int gud_probe(struct usb_interface *intf, const struct usb_device_id *id drm->mode_config.max_width = le32_to_cpu(desc.max_width); drm->mode_config.min_height = le32_to_cpu(desc.min_height); drm->mode_config.max_height = le32_to_cpu(desc.max_height); + + if (!drm->mode_config.min_width || !drm->mode_config.min_height || + drm->mode_config.max_width < drm->mode_config.min_width || + drm->mode_config.max_height < drm->mode_config.min_height) + return -EINVAL; + drm->mode_config.funcs = &gud_mode_config_funcs; drm->mode_config.helper_private = &gud_mode_config_helpers;