Skip to content

Commit

Permalink
drm/client: fix null pointer dereference in drm_client_modeset_probe
Browse files Browse the repository at this point in the history
commit 113fd63 upstream.

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: [email protected]
Fixes: cf13909 ("drm/fb-helper: Move out modeset config code")
Signed-off-by: Ma Ke <[email protected]>
Reviewed-by: Thomas Zimmermann <[email protected]>
Signed-off-by: Thomas Zimmermann <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Ma Ke authored and gregkh committed Aug 14, 2024
1 parent d73de3c commit d64fc94
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/gpu/drm/drm_client_modeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ 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) {
ret = -ENOMEM;
break;
}

drm_connector_get(connector);
modeset->connectors[modeset->num_connectors++] = connector;
modeset->x = offset->x;
Expand Down

0 comments on commit d64fc94

Please sign in to comment.