]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/sun4i: tv: Check mode pointer
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Mon, 19 Sep 2016 20:17:51 +0000 (22:17 +0200)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Thu, 22 Sep 2016 07:13:08 +0000 (10:13 +0300)
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>
drivers/gpu/drm/sun4i/sun4i_tv.c

index 3d69bd34f36c34029c1261d62e7a04fe3fb2de26..1dd3d9eabf2e5098c617d72001bdcc3a82737629 100644 (file)
@@ -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);