Skip to contentSkip to conversation

drm/gma500: fix double free of gma_connector

PATCH In review [email protected] 2 participants 2 messages Oct 3, 2020 – Oct 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/gma500: fix double free of gma_connector

From: Tom Rix <[email protected]>

clang static analysis reports this problem:

cdv_intel_dp.c:2101:2: warning: Attempt to free released memory

        kfree(gma_connector);
        ^~~~~~~~~~~~~~~~~~~~

In cdv_intel_dp_init() when the call to cdv_intel_edp_panel_vdd_off() fails, the handler calls cdv_intel_dp_destroy(connector) which does the first free of gma_connector. So adjust the goto label and skip the second free.

Fixes d112a8163f83 ("gma500/cdv: Add eDP support")
---
 drivers/gpu/drm/gma500/cdv_intel_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/gma500/cdv_intel_dp.c +1 -1
index 720a767118c9..deb4fd13591d 100644
@@ -2083,7 +2083,7 @@ cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev
 			DRM_INFO("failed to retrieve link info, disabling eDP\n");
 			drm_encoder_cleanup(encoder);
 			cdv_intel_dp_destroy(connector);
-			goto err_priv;
+			goto err_connector;
 		} else {
         		DRM_DEBUG_KMS("DPCD: Rev=%x LN_Rate=%x LN_CNT=%x LN_DOWNSP=%x\n",
 				intel_dp->dpcd[0], intel_dp->dpcd[1], 
Signature · 1 line
2.18.1
#1 lore raw
Quoted 8 lines · On Sat, Oct 03, 2020 at 12:39:28PM -0700, [email protected] wrote:

From: Tom Rix <[email protected]>

clang static analysis reports this problem:

cdv_intel_dp.c:2101:2: warning: Attempt to free released memory

        kfree(gma_connector);
        ^~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

In cdv_intel_dp_init() when the call to cdv_intel_edp_panel_vdd_off() fails, the handler calls cdv_intel_dp_destroy(connector) which does the first free of gma_connector. So adjust the goto label and skip the second free.

Fixes d112a8163f83 ("gma500/cdv: Add eDP support")

Thanks for your patch, queued in drm-misc-next for 5.11. -Daniel

Quoted 20 lines
---
 drivers/gpu/drm/gma500/cdv_intel_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/gma500/cdv_intel_dp.c +1 -1
index 720a767118c9..deb4fd13591d 100644
@@ -2083,7 +2083,7 @@ cdv_intel_dp_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev
 			DRM_INFO("failed to retrieve link info, disabling eDP\n");
 			drm_encoder_cleanup(encoder);
 			cdv_intel_dp_destroy(connector);
-			goto err_priv;
+			goto err_connector;
 		} else {
         		DRM_DEBUG_KMS("DPCD: Rev=%x LN_Rate=%x LN_CNT=%x LN_DOWNSP=%x\n",
 				intel_dp->dpcd[0], intel_dp->dpcd[1], 
Signature · 1 line
2.18.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch