diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-04-29 13:42:32 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-05-19 09:56:40 +0300 |
commit | 3f9c1c872cc97875ddc8d63bc9fe6ee13652b933 (patch) | |
tree | 8d8e5e9068bbb59cb4e554bba86bd1eb62f68660 | |
parent | 5bebaeadb30e8d1ed694bd9b63d4e424d333fe36 (diff) | |
download | linux-3f9c1c872cc97875ddc8d63bc9fe6ee13652b933.tar.bz2 |
drm/tilcdc: fix leak & null ref in panel_connector_get_modes
If videomode_from_timings() returns true, the mode allocated with
drm_mode_create will be leaked.
Also, the return value of drm_mode_create() is never checked, and thus
could cause NULL deref.
Fix these two issues.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200429104234.18910-1-tomi.valkeinen@ti.com
Reviewed-by: Jyri Sarha <jsarha@ti.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index b207b2f19d42..1c9fa8cfcd49 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -139,12 +139,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) int i; for (i = 0; i < timings->num_timings; i++) { - struct drm_display_mode *mode = drm_mode_create(dev); + struct drm_display_mode *mode; struct videomode vm; if (videomode_from_timings(timings, &vm, i)) break; + mode = drm_mode_create(dev); + if (!mode) + break; + drm_display_mode_from_videomode(&vm, mode); mode->type = DRM_MODE_TYPE_DRIVER; |