Skip to content

Commit

Permalink
drm/omap: handle alloc failures in omap_connector
Browse files Browse the repository at this point in the history
Handle memory allocation failures in omap_connector to avoid NULL
derefs.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180502091159.7071-5-tomi.valkeinen@ti.com
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
  • Loading branch information
Tomi Valkeinen authored and Sean Paul committed May 7, 2018
1 parent 7f26eee commit 47aaaec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/gpu/drm/omapdrm/omap_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ static int omap_connector_get_modes(struct drm_connector *connector)
if (dssdrv->read_edid) {
void *edid = kzalloc(MAX_EDID, GFP_KERNEL);

if (!edid)
return 0;

if ((dssdrv->read_edid(dssdev, edid, MAX_EDID) > 0) &&
drm_edid_is_valid(edid)) {
drm_mode_connector_update_edid_property(
Expand All @@ -139,6 +142,9 @@ static int omap_connector_get_modes(struct drm_connector *connector)
struct drm_display_mode *mode = drm_mode_create(dev);
struct videomode vm = {0};

if (!mode)
return 0;

dssdrv->get_timings(dssdev, &vm);

drm_display_mode_from_videomode(&vm, mode);
Expand Down Expand Up @@ -200,6 +206,10 @@ static int omap_connector_mode_valid(struct drm_connector *connector,
if (!r) {
/* check if vrefresh is still valid */
new_mode = drm_mode_duplicate(dev, mode);

if (!new_mode)
return MODE_BAD;

new_mode->clock = vm.pixelclock / 1000;
new_mode->vrefresh = 0;
if (mode->vrefresh == drm_mode_vrefresh(new_mode))
Expand Down

0 comments on commit 47aaaec

Please sign in to comment.