Skip to content

Commit 8ad49a9

Browse files
mwalleChun-Kuang Hu
authored andcommitted
drm/mediatek/dp: Fix spurious kfree()
drm_edid_to_sad() might return an error or just zero. If that is the case, we must not free the SADs because there was no allocation in the first place. Fixes: dab12fa ("drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection") Signed-off-by: Michael Walle <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Jani Nikula <[email protected]> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 9ff6df4 commit 8ad49a9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,9 +2073,15 @@ static const struct drm_edid *mtk_dp_edid_read(struct drm_bridge *bridge,
20732073
*/
20742074
const struct edid *edid = drm_edid_raw(drm_edid);
20752075
struct cea_sad *sads;
2076+
int ret;
20762077

2077-
audio_caps->sad_count = drm_edid_to_sad(edid, &sads);
2078-
kfree(sads);
2078+
ret = drm_edid_to_sad(edid, &sads);
2079+
/* Ignore any errors */
2080+
if (ret < 0)
2081+
ret = 0;
2082+
if (ret)
2083+
kfree(sads);
2084+
audio_caps->sad_count = ret;
20792085

20802086
/*
20812087
* FIXME: This should use connector->display_info.has_audio from

0 commit comments

Comments
 (0)