]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/imx: Fix memory leak in imx_pd_connector_get_modes
authorJosé Expósito <jose.exposito89@gmail.com>
Sat, 8 Jan 2022 16:52:30 +0000 (17:52 +0100)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 4 Apr 2022 07:37:42 +0000 (09:37 +0200)
Avoid leaking the display mode variable if of_get_drm_display_mode
fails.

Fixes: 76ecd9c9fb24 ("drm/imx: parallel-display: check return code from of_get_drm_display_mode()")
Addresses-Coverity-ID: 1443943 ("Resource leak")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20220108165230.44610-1-jose.exposito89@gmail.com
drivers/gpu/drm/imx/parallel-display.c

index 06cb1a59b9bcd6fd38f573abfdbca904f9a69cc2..63ba2ad84679183af60a635ea3f014f2f47d0bba 100644 (file)
@@ -75,8 +75,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
                ret = of_get_drm_display_mode(np, &imxpd->mode,
                                              &imxpd->bus_flags,
                                              OF_USE_NATIVE_MODE);
-               if (ret)
+               if (ret) {
+                       drm_mode_destroy(connector->dev, mode);
                        return ret;
+               }
 
                drm_mode_copy(mode, &imxpd->mode);
                mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;