Commit 8ad49a92 authored by Michael Walle's avatar Michael Walle Committed by Chun-Kuang Hu

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: dab12fa8 ("drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection")
Signed-off-by: default avatarMichael Walle <mwalle@kernel.org>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20240604083337.1879188-1-mwalle@kernel.org/Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
parent 9ff6df49
...@@ -2073,9 +2073,15 @@ static const struct drm_edid *mtk_dp_edid_read(struct drm_bridge *bridge, ...@@ -2073,9 +2073,15 @@ static const struct drm_edid *mtk_dp_edid_read(struct drm_bridge *bridge,
*/ */
const struct edid *edid = drm_edid_raw(drm_edid); const struct edid *edid = drm_edid_raw(drm_edid);
struct cea_sad *sads; struct cea_sad *sads;
int ret;
audio_caps->sad_count = drm_edid_to_sad(edid, &sads); ret = drm_edid_to_sad(edid, &sads);
/* Ignore any errors */
if (ret < 0)
ret = 0;
if (ret)
kfree(sads); kfree(sads);
audio_caps->sad_count = ret;
/* /*
* FIXME: This should use connector->display_info.has_audio from * FIXME: This should use connector->display_info.has_audio from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment