Skip to content

Commit c9a3e48

Browse files
Ma Keroxanan1996
authored andcommitted
drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_hd_modes
BugLink: https://bugs.launchpad.net/bugs/2073765 commit 6d411c8ccc0137a612e0044489030a194ff5c843 upstream. In nv17_tv_get_hd_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a possible NULL pointer dereference on failure of drm_mode_duplicate(). The same applies to drm_cvt_mode(). Add a check to avoid null pointer dereference. Cc: stable@vger.kernel.org Signed-off-by: Ma Ke <make24@iscas.ac.cn> Signed-off-by: Lyude Paul <lyude@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240625081029.2619437-1-make24@iscas.ac.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent a382f80 commit c9a3e48

File tree

1 file changed

+4
-0
lines changed
  • drivers/gpu/drm/nouveau/dispnv04

1 file changed

+4
-0
lines changed

drivers/gpu/drm/nouveau/dispnv04/tvnv17.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,17 @@ static int nv17_tv_get_hd_modes(struct drm_encoder *encoder,
259259
if (modes[i].hdisplay == output_mode->hdisplay &&
260260
modes[i].vdisplay == output_mode->vdisplay) {
261261
mode = drm_mode_duplicate(encoder->dev, output_mode);
262+
if (!mode)
263+
continue;
262264
mode->type |= DRM_MODE_TYPE_PREFERRED;
263265

264266
} else {
265267
mode = drm_cvt_mode(encoder->dev, modes[i].hdisplay,
266268
modes[i].vdisplay, 60, false,
267269
(output_mode->flags &
268270
DRM_MODE_FLAG_INTERLACE), false);
271+
if (!mode)
272+
continue;
269273
}
270274

271275
/* CVT modes are sometimes unsuitable... */

0 commit comments

Comments
 (0)