diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2018-05-02 05:11:59 -0400 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2018-05-07 10:19:12 -0400 |
commit | 47aaaec818dfd1009d1358974a2931f05dd57203 (patch) | |
tree | 3e5a98dd92c29823bac34880ab83dc3c45a0618f /drivers/gpu/drm/omapdrm/omap_connector.c | |
parent | 7f26eee572167926806b6fcb703bb5f8e452c398 (diff) |
drm/omap: handle alloc failures in omap_connector
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>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_connector.c')
-rw-r--r-- | drivers/gpu/drm/omapdrm/omap_connector.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index a0d7b1d905e8..5cde26ac937b 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c | |||
@@ -121,6 +121,9 @@ static int omap_connector_get_modes(struct drm_connector *connector) | |||
121 | if (dssdrv->read_edid) { | 121 | if (dssdrv->read_edid) { |
122 | void *edid = kzalloc(MAX_EDID, GFP_KERNEL); | 122 | void *edid = kzalloc(MAX_EDID, GFP_KERNEL); |
123 | 123 | ||
124 | if (!edid) | ||
125 | return 0; | ||
126 | |||
124 | if ((dssdrv->read_edid(dssdev, edid, MAX_EDID) > 0) && | 127 | if ((dssdrv->read_edid(dssdev, edid, MAX_EDID) > 0) && |
125 | drm_edid_is_valid(edid)) { | 128 | drm_edid_is_valid(edid)) { |
126 | drm_mode_connector_update_edid_property( | 129 | drm_mode_connector_update_edid_property( |
@@ -139,6 +142,9 @@ static int omap_connector_get_modes(struct drm_connector *connector) | |||
139 | struct drm_display_mode *mode = drm_mode_create(dev); | 142 | struct drm_display_mode *mode = drm_mode_create(dev); |
140 | struct videomode vm = {0}; | 143 | struct videomode vm = {0}; |
141 | 144 | ||
145 | if (!mode) | ||
146 | return 0; | ||
147 | |||
142 | dssdrv->get_timings(dssdev, &vm); | 148 | dssdrv->get_timings(dssdev, &vm); |
143 | 149 | ||
144 | drm_display_mode_from_videomode(&vm, mode); | 150 | drm_display_mode_from_videomode(&vm, mode); |
@@ -200,6 +206,10 @@ static int omap_connector_mode_valid(struct drm_connector *connector, | |||
200 | if (!r) { | 206 | if (!r) { |
201 | /* check if vrefresh is still valid */ | 207 | /* check if vrefresh is still valid */ |
202 | new_mode = drm_mode_duplicate(dev, mode); | 208 | new_mode = drm_mode_duplicate(dev, mode); |
209 | |||
210 | if (!new_mode) | ||
211 | return MODE_BAD; | ||
212 | |||
203 | new_mode->clock = vm.pixelclock / 1000; | 213 | new_mode->clock = vm.pixelclock / 1000; |
204 | new_mode->vrefresh = 0; | 214 | new_mode->vrefresh = 0; |
205 | if (mode->vrefresh == drm_mode_vrefresh(new_mode)) | 215 | if (mode->vrefresh == drm_mode_vrefresh(new_mode)) |