From 39dcf4f708992318ba331319a69ff77db4e70864 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 26 Feb 2014 20:53:42 -0300 Subject: [PATCH] imx-drm: parallel-display: Check 'mode' pointer first 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 Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/parallel-display.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index 6bce1405efd2..c60b6c645f42 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -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, -- 2.30.2