public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/client: fix null pointer dereference in drm_client_modeset_probe
@ 2024-07-24  9:45 Ma Ke
  2024-07-24 10:03 ` Jani Nikula
  0 siblings, 1 reply; 5+ messages in thread
From: Ma Ke @ 2024-07-24  9:45 UTC (permalink / raw)
  To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel, sam,
	noralf
  Cc: dri-devel, linux-kernel, Ma Ke, stable

In drm_client_modeset_probe(), the return value of drm_mode_duplicate() is
assigned to modeset->mode, which will lead to a possible NULL pointer
dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.

Cc: stable@vger.kernel.org
Fixes: cf13909aee05 ("drm/fb-helper: Move out modeset config code")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
Changes in v3:
- modified patch as suggestions, returned error directly when failing to 
get modeset->mode.
Changes in v2:
- added the recipient's email address, due to the prolonged absence of a 
response from the recipients.
- added Cc stable.
---
 drivers/gpu/drm/drm_client_modeset.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index 31af5cf37a09..750b8dce0f90 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -880,6 +880,9 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 
 			kfree(modeset->mode);
 			modeset->mode = drm_mode_duplicate(dev, mode);
+			if (!modeset->mode)
+				return 0;
+
 			drm_connector_get(connector);
 			modeset->connectors[modeset->num_connectors++] = connector;
 			modeset->x = offset->x;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-25  1:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24  9:45 [PATCH v3] drm/client: fix null pointer dereference in drm_client_modeset_probe Ma Ke
2024-07-24 10:03 ` Jani Nikula
2024-07-24 10:55   ` Ma Ke
2024-07-24 14:50     ` Jani Nikula
2024-07-25  1:38       ` Ma Ke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox