Skip to contentSkip to conversation

drm/gma500: fix memory leak on edid

PATCH In review Colin King 2 participants 2 messages Mar 20, 2017

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/gma500: fix memory leak on edid

From: Colin Ian King <[email protected]>

edid is allocated on the call to psb_intel_sdvo_get_edid but not kfree'd at all, causing a memory leak. Fix this by kfree'ing the edid. (This may be null, but kfree can handle null frees).

Detected by CoverityScan, CID#1090730 ("Resource Leak")

Fixes 5736995b473b ("gma500: Replace SDVO code with slightly modified version from i915")
---
 drivers/gpu/drm/gma500/psb_intel_sdvo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/gma500/psb_intel_sdvo.c +1 -0
index e787d376ba67..f38e6ad1ab9b 100644
@@ -1650,6 +1650,7 @@ static bool psb_intel_sdvo_detect_hdmi_audio(struct drm_connector *connector)
 	edid = psb_intel_sdvo_get_edid(connector);
 	if (edid != NULL && edid->input & DRM_EDID_INPUT_DIGITAL)
 		has_audio = drm_detect_monitor_audio(edid);
+	kfree(edid);
 
 	return has_audio;
 }
Signature · 1 line
2.11.0
#1 lore raw

Am 20.03.2017 18:56, schrieb Colin King:

Quoted 19 lines

From: Colin Ian King <[email protected]>

edid is allocated on the call to psb_intel_sdvo_get_edid but not kfree'd at all, causing a memory leak. Fix this by kfree'ing the edid. (This may be null, but kfree can handle null frees).

Detected by CoverityScan, CID#1090730 ("Resource Leak")

Fixes 5736995b473b ("gma500: Replace SDVO code with slightly modified version from i915")
---
 drivers/gpu/drm/gma500/psb_intel_sdvo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/gma500/psb_intel_sdvo.c +0 -0
index e787d376ba67..f38e6ad1ab9b 100644

drivers/gpu/drm/gma500/psb_intel_sdvo.c static bool psb_intel_sdvo_detect_hdmi_audio(struct drm_connector *connector) · line 1651

Quoted 2 lines
drivers/gpu/drm/gma500/psb_intel_sdvo.c +0 -0
@@ -1650,6 +1650,7 @@ static bool psb_intel_sdvo_detect_hdmi_audio(struct drm_connector *connector)
 	edid = psb_intel_sdvo_get_edid(connector);
 	if (edid != NULL && edid->input & DRM_EDID_INPUT_DIGITAL)

is the check here needed at all ?

	drm_detect_monitor_audio--> drm_find_cea_extension -->drm_find_edid_extension (will check for NULL)

I missed DRM_EDID_INPUT_DIGITAL some where ? NTL i would expected drm_detect_monitor_audio to hanle it savely.

re,
wh

Quoted 5 lines
drivers/gpu/drm/gma500/psb_intel_sdvo.c +1 -0
 		has_audio = drm_detect_monitor_audio(edid);
+	kfree(edid);
 
 	return has_audio;
 }