Skip to content

Commit 6d411c8

Browse files
Ma KeLyude
authored andcommitted
drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_hd_modes
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: [email protected] Signed-off-by: Ma Ke <[email protected]> Signed-off-by: Lyude Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 37ce99b commit 6d411c8

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
@@ -258,13 +258,17 @@ static int nv17_tv_get_hd_modes(struct drm_encoder *encoder,
258258
if (modes[i].hdisplay == output_mode->hdisplay &&
259259
modes[i].vdisplay == output_mode->vdisplay) {
260260
mode = drm_mode_duplicate(encoder->dev, output_mode);
261+
if (!mode)
262+
continue;
261263
mode->type |= DRM_MODE_TYPE_PREFERRED;
262264

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

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

0 commit comments

Comments
 (0)