diff mbox series

drm/bridge: tc358767: fix EDID memory leak

Message ID 20200826134017.437486-1-tomi.valkeinen@ti.com (mailing list archive)
State New, archived
Headers show
Series drm/bridge: tc358767: fix EDID memory leak | expand

Commit Message

Tomi Valkeinen Aug. 26, 2020, 1:40 p.m. UTC
The current EDID allocated with drm_get_edid() is freed when the driver
gets a new EDID, but it is not freed when the driver is removed, causing
a leak.

Free the EDID (if any) on driver remove.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/bridge/tc358767.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andrzej Hajda Aug. 26, 2020, 3:54 p.m. UTC | #1
On 26.08.2020 15:40, Tomi Valkeinen wrote:
> The current EDID allocated with drm_get_edid() is freed when the driver
> gets a new EDID, but it is not freed when the driver is removed, causing
> a leak.
>
> Free the EDID (if any) on driver remove.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

Regards
Andrzej
Laurent Pinchart Aug. 26, 2020, 11:23 p.m. UTC | #2
Hi Tomi,

Thank you for the patch.

On Wed, Aug 26, 2020 at 04:40:17PM +0300, Tomi Valkeinen wrote:
> The current EDID allocated with drm_get_edid() is freed when the driver
> gets a new EDID, but it is not freed when the driver is removed, causing
> a leak.
> 
> Free the EDID (if any) on driver remove.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/bridge/tc358767.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index c2777b226c75..dbb18a86beaf 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1695,6 +1695,8 @@ static int tc_remove(struct i2c_client *client)
>  	drm_bridge_remove(&tc->bridge);
>  	drm_dp_aux_unregister(&tc->aux);
>  
> +	kfree(tc->edid);
> +

tc->edid is gone in drm-misc-next, problem solved already :-)

>  	return 0;
>  }
Tomi Valkeinen Aug. 27, 2020, 5:18 a.m. UTC | #3
On 27/08/2020 02:23, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Wed, Aug 26, 2020 at 04:40:17PM +0300, Tomi Valkeinen wrote:
>> The current EDID allocated with drm_get_edid() is freed when the driver
>> gets a new EDID, but it is not freed when the driver is removed, causing
>> a leak.
>>
>> Free the EDID (if any) on driver remove.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/bridge/tc358767.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
>> index c2777b226c75..dbb18a86beaf 100644
>> --- a/drivers/gpu/drm/bridge/tc358767.c
>> +++ b/drivers/gpu/drm/bridge/tc358767.c
>> @@ -1695,6 +1695,8 @@ static int tc_remove(struct i2c_client *client)
>>  	drm_bridge_remove(&tc->bridge);
>>  	drm_dp_aux_unregister(&tc->aux);
>>  
>> +	kfree(tc->edid);
>> +
> 
> tc->edid is gone in drm-misc-next, problem solved already :-)

Well, indeed. Should have looked at the latest... =). The leak only happens on driver remove, so I
don't think it's worth sending for stable kernels.

 Tomi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index c2777b226c75..dbb18a86beaf 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -1695,6 +1695,8 @@  static int tc_remove(struct i2c_client *client)
 	drm_bridge_remove(&tc->bridge);
 	drm_dp_aux_unregister(&tc->aux);
 
+	kfree(tc->edid);
+
 	return 0;
 }