mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hui Peng <benquike@gmail.com>
To: "Noralf Trønnes" <noralf@tronnes.org>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Hui Peng <benquike@gmail.com>
Subject: [PATCH v2 1/5] drm/gud: Fix probe failure on non-DMA devices by moving descriptor check
Date: Wed, 30 Sep 2026 06:59:10 +0000	[thread overview]
Message-ID: <20260930065914.393939-2-benquike@gmail.com> (raw)
In-Reply-To: <20260930065914.393939-1-benquike@gmail.com>

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 <benquike@gmail.com>
---
 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;
 

  reply	other threads:[~2026-09-30  6:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  6:59 [PATCH v2 0/5] drm/gud: fix probe validation, shadow_buf UAF, and bulk_len divide-by-zero Hui Peng
2026-09-30  6:59 ` Hui Peng [this message]
2026-09-30  6:59 ` [PATCH v2 2/5] drm/gud: Align both x1 and x2 to block_width in gud_flush_damage() Hui Peng
2026-09-30  6:59 ` [PATCH v2 3/5] drm/gud: Prevent shadow_buf UAF by flushing work before reallocating Hui Peng
2026-09-30  6:59 ` [PATCH v2 4/5] drm/gud: Fix bulk_len divide-by-zero in gud_flush_damage() Hui Peng
2026-09-30  6:59 ` [PATCH v2 5/5] drm/gud: Reset damage state on vcalloc ENOMEM failure Hui Peng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930065914.393939-2-benquike@gmail.com \
    --to=benquike@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®