drm: Check if the allocation has succeeded before dereferencing newmode

We allocate memory in drm_display_mode_from_vic_index() and use it
without checking the pointer is valid. Fix that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Damien Lespiau 2014-03-03 23:59:07 +00:00 committed by Daniel Vetter
parent 366d480700
commit 409bbf1e3d
1 changed files with 3 additions and 0 deletions

View File

@ -2580,6 +2580,9 @@ drm_display_mode_from_vic_index(struct drm_connector *connector,
return NULL; return NULL;
newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
if (!newmode)
return NULL;
newmode->vrefresh = 0; newmode->vrefresh = 0;
return newmode; return newmode;