2022-05-16 18:31:52

by Hangyu Hua

[permalink] [raw]
Subject: [PATCH] drm: dp: fix a possible memory leak in fetch_monitor_name()

drm_dp_mst_get_edid call kmemdup to create mst_edid. So mst_edid need to be
freed after use.

Signed-off-by: Hangyu Hua <[email protected]>
---
drivers/gpu/drm/dp/drm_dp_mst_topology.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/dp/drm_dp_mst_topology.c b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
index 11300b53d24f..7a7cc44686f9 100644
--- a/drivers/gpu/drm/dp/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
@@ -4852,6 +4852,7 @@ static void fetch_monitor_name(struct drm_dp_mst_topology_mgr *mgr,

mst_edid = drm_dp_mst_get_edid(port->connector, mgr, port);
drm_edid_get_monitor_name(mst_edid, name, namelen);
+ kfree(mst_edid);
}

/**
--
2.25.1



2022-05-18 04:15:55

by Lyude Paul

[permalink] [raw]
Subject: Re: [PATCH] drm: dp: fix a possible memory leak in fetch_monitor_name()

Reviewed-by: Lyude Paul <[email protected]>

Will push to the appropriate branch in a bit

On Mon, 2022-05-16 at 11:20 +0800, Hangyu Hua wrote:
> drm_dp_mst_get_edid call kmemdup to create mst_edid. So mst_edid need to be
> freed after use.
>
> Signed-off-by: Hangyu Hua <[email protected]>
> ---
>  drivers/gpu/drm/dp/drm_dp_mst_topology.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> index 11300b53d24f..7a7cc44686f9 100644
> --- a/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/dp/drm_dp_mst_topology.c
> @@ -4852,6 +4852,7 @@ static void fetch_monitor_name(struct
> drm_dp_mst_topology_mgr *mgr,
>  
>         mst_edid = drm_dp_mst_get_edid(port->connector, mgr, port);
>         drm_edid_get_monitor_name(mst_edid, name, namelen);
> +       kfree(mst_edid);
>  }
>  
>  /**

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat