imx-drm: parallel-display: Check 'mode' pointer first
authorFabio Estevam <fabio.estevam@freescale.com>
Wed, 26 Feb 2014 23:53:42 +0000 (20:53 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Feb 2014 22:57:43 +0000 (14:57 -0800)
Fix the following static checker warnings:

drivers/staging/imx-drm/parallel-display.c:64 imx_pd_connector_get_modes() error: potential null dereference 'mode'.  (drm_mode_create returns null)
drivers/staging/imx-drm/parallel-display.c:73 imx_pd_connector_get_modes() error: potential null dereference 'mode'.  (drm_mode_create returns null)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/imx-drm/parallel-display.c

index 6bce1405efd2657a9230f26ea0fcaada2262c810..c60b6c645f42000df73f7ee4ba198cca6c65d27f 100644 (file)
@@ -70,6 +70,8 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
 
        if (imxpd->mode_valid) {
                struct drm_display_mode *mode = drm_mode_create(connector->dev);
+               if (!mode)
+                       return -EINVAL;
                drm_mode_copy(mode, &imxpd->mode);
                mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
                drm_mode_probed_add(connector, mode);
@@ -78,6 +80,8 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
 
        if (np) {
                struct drm_display_mode *mode = drm_mode_create(connector->dev);
+               if (!mode)
+                       return -EINVAL;
                of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
                drm_mode_copy(mode, &imxpd->mode);
                mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,