summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/sun4i/sun4i_tv.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2016-09-19 23:17:51 +0300
committerMaxime Ripard <maxime.ripard@free-electrons.com>2016-09-22 10:13:08 +0300
commite4192089fe5320537fd88aa29721277efef64af4 (patch)
treed4b88d9c1104621d815bb6725c150974668d3b10 /drivers/gpu/drm/sun4i/sun4i_tv.c
parentc222f399045de480d4af0b9e4cdfff1a083e3e1d (diff)
downloadlinux-e4192089fe5320537fd88aa29721277efef64af4.tar.xz
drm/sun4i: tv: Check mode pointer
The drm_mode_create call might return NULL in case of a failure, and the current code doesn't check for that. Make sure it does. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Diffstat (limited to 'drivers/gpu/drm/sun4i/sun4i_tv.c')
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tv.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
index 3d69bd34f36c..1dd3d9eabf2e 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
@@ -507,9 +507,15 @@ static int sun4i_tv_comp_get_modes(struct drm_connector *connector)
int i;
for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
- struct drm_display_mode *mode = drm_mode_create(connector->dev);
+ struct drm_display_mode *mode;
const struct tv_mode *tv_mode = &tv_modes[i];
+ mode = drm_mode_create(connector->dev);
+ if (!mode) {
+ DRM_ERROR("Failed to create a new display mode\n");
+ return 0;
+ }
+
strcpy(mode->name, tv_mode->name);
sun4i_tv_mode_to_drm_mode(tv_mode, mode);