[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87v83ca8g6.fsf@intel.com>
Date: Fri, 17 May 2024 16:12:25 +0300
From: Jani Nikula <jani.nikula@...el.com>
To: Michael Walle <mwalle@...nel.org>, Chun-Kuang Hu
<chunkuang.hu@...nel.org>, Philipp Zabel <p.zabel@...gutronix.de>, David
Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>, Matthias
Brugger <matthias.bgg@...il.com>, AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
Cc: Chen-Yu Tsai <wenst@...omium.org>, linux-mediatek@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Michael Walle <mwalle@...nel.org>
Subject: Re: [PATCH] drm/mediatek/dp: fix spurious kfree()
On Fri, 17 May 2024, Michael Walle <mwalle@...nel.org> wrote:
> 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: dab12fa8d2bd ("drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection")
> Signed-off-by: Michael Walle <mwalle@...nel.org>
> ---
> drivers/gpu/drm/mediatek/mtk_dp.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index 536366956447..ada12927bbac 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -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);
> struct cea_sad *sads;
I suppose I would've just initialized sads = NULL; and be done with it.
But *shrug*.
Reviewed-by: Jani Nikula <jani.nikula@...el.com>
> + int ret;
>
> - audio_caps->sad_count = drm_edid_to_sad(edid, &sads);
> - kfree(sads);
> + ret = drm_edid_to_sad(edid, &sads);
> + /* Ignore any errors */
> + if (ret < 0)
> + ret = 0;
> + if (ret)
> + kfree(sads);
> + audio_caps->sad_count = ret;
>
> /*
> * FIXME: This should use connector->display_info.has_audio from
--
Jani Nikula, Intel
Powered by blists - more mailing lists