diff mbox series

drm/mediatek/dp: fix memory leak on ->get_edid callback error path

Message ID 20230914131058.2472260-1-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/mediatek/dp: fix memory leak on ->get_edid callback error path | expand

Commit Message

Jani Nikula Sept. 14, 2023, 1:10 p.m. UTC
Setting new_edid to NULL leaks the buffer.

Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
Cc: Markus Schneider-Pargmann <msp@baylibre.com>
Cc: Guillaume Ranquet <granquet@baylibre.com>
Cc: Bo-Chen Chen <rex-bc.chen@mediatek.com>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: <stable@vger.kernel.org> # v6.1+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

UNTESTED
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Guillaume Ranquet Sept. 14, 2023, 1:38 p.m. UTC | #1
On Thu, 14 Sep 2023 15:10, Jani Nikula <jani.nikula@intel.com> wrote:
>Setting new_edid to NULL leaks the buffer.
>
>Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
>Cc: Markus Schneider-Pargmann <msp@baylibre.com>
>Cc: Guillaume Ranquet <granquet@baylibre.com>
>Cc: Bo-Chen Chen <rex-bc.chen@mediatek.com>
>Cc: CK Hu <ck.hu@mediatek.com>
>Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
>Cc: Philipp Zabel <p.zabel@pengutronix.de>
>Cc: Matthias Brugger <matthias.bgg@gmail.com>
>Cc: dri-devel@lists.freedesktop.org
>Cc: linux-mediatek@lists.infradead.org
>Cc: linux-kernel@vger.kernel.org
>Cc: linux-arm-kernel@lists.infradead.org
>Cc: <stable@vger.kernel.org> # v6.1+
>Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>

Reviewed-by: Guillaume Ranquet <granquet@baylibre.com>
>---
>
>UNTESTED
>---
> drivers/gpu/drm/mediatek/mtk_dp.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
>index 2cb47f663756..8fc6eff68e30 100644
>--- a/drivers/gpu/drm/mediatek/mtk_dp.c
>+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
>@@ -2049,6 +2049,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
> 	 */
> 	if (mtk_dp_parse_capabilities(mtk_dp)) {
> 		drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
>+		kfree(new_edid);
> 		new_edid = NULL;
> 	}
>
>--
>2.39.2
>
Chun-Kuang Hu Sept. 24, 2023, 2:40 p.m. UTC | #2
Hi, Jani:

Jani Nikula <jani.nikula@intel.com> 於 2023年9月14日 週四 下午9:13寫道:
>
> Setting new_edid to NULL leaks the buffer.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
> Cc: Markus Schneider-Pargmann <msp@baylibre.com>
> Cc: Guillaume Ranquet <granquet@baylibre.com>
> Cc: Bo-Chen Chen <rex-bc.chen@mediatek.com>
> Cc: CK Hu <ck.hu@mediatek.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: <stable@vger.kernel.org> # v6.1+
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> ---
>
> UNTESTED
> ---
>  drivers/gpu/drm/mediatek/mtk_dp.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index 2cb47f663756..8fc6eff68e30 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -2049,6 +2049,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
>          */
>         if (mtk_dp_parse_capabilities(mtk_dp)) {
>                 drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
> +               kfree(new_edid);
>                 new_edid = NULL;
>         }
>
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 2cb47f663756..8fc6eff68e30 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2049,6 +2049,7 @@  static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
 	 */
 	if (mtk_dp_parse_capabilities(mtk_dp)) {
 		drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
+		kfree(new_edid);
 		new_edid = NULL;
 	}