diff mbox series

drm/meson: fix memory leak on ->hpd_notify callback

Message ID 20230914131015.2472029-1-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/meson: fix memory leak on ->hpd_notify callback | expand

Commit Message

Jani Nikula Sept. 14, 2023, 1:10 p.m. UTC
The EDID returned by drm_bridge_get_edid() needs to be freed.

Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-amlogic@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: <stable@vger.kernel.org> # v5.17+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

UNTESTED
---
 drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Neil Armstrong Sept. 15, 2023, 6:59 a.m. UTC | #1
On 14/09/2023 15:10, Jani Nikula wrote:
> The EDID returned by drm_bridge_get_edid() needs to be freed.
> 
> Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Cc: Neil Armstrong <neil.armstrong@linaro.org>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-amlogic@lists.infradead.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: <stable@vger.kernel.org> # v5.17+
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> 
> ---
> 
> UNTESTED
> ---
>   drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> index 9913971fa5d2..25ea76558690 100644
> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
> @@ -334,6 +334,8 @@ static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge,
>   			return;
>   
>   		cec_notifier_set_phys_addr_from_edid(encoder_hdmi->cec_notifier, edid);
> +
> +		kfree(edid);
>   	} else
>   		cec_notifier_phys_addr_invalidate(encoder_hdmi->cec_notifier);
>   }

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Jani Nikula Sept. 19, 2023, 9:54 a.m. UTC | #2
On Fri, 15 Sep 2023, Neil Armstrong <neil.armstrong@linaro.org> wrote:
> On 14/09/2023 15:10, Jani Nikula wrote:
>> The EDID returned by drm_bridge_get_edid() needs to be freed.
>> 
>> Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")
>> Cc: Neil Armstrong <narmstrong@baylibre.com>
>> Cc: Sam Ravnborg <sam@ravnborg.org>
>> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>> Cc: Neil Armstrong <neil.armstrong@linaro.org>
>> Cc: Kevin Hilman <khilman@baylibre.com>
>> Cc: Jerome Brunet <jbrunet@baylibre.com>
>> Cc: dri-devel@lists.freedesktop.org
>> Cc: linux-amlogic@lists.infradead.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: <stable@vger.kernel.org> # v5.17+
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> 
>> ---
>> 
>> UNTESTED
>> ---
>>   drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 ++
>>   1 file changed, 2 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>> index 9913971fa5d2..25ea76558690 100644
>> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>> @@ -334,6 +334,8 @@ static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge,
>>   			return;
>>   
>>   		cec_notifier_set_phys_addr_from_edid(encoder_hdmi->cec_notifier, edid);
>> +
>> +		kfree(edid);
>>   	} else
>>   		cec_notifier_phys_addr_invalidate(encoder_hdmi->cec_notifier);
>>   }
>
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks. I don't seem to have a toolchain to get this to build... would
you mind applying this, please?

BR,
Jani.
Neil Armstrong Sept. 19, 2023, 12:09 p.m. UTC | #3
On 19/09/2023 11:54, Jani Nikula wrote:
> On Fri, 15 Sep 2023, Neil Armstrong <neil.armstrong@linaro.org> wrote:
>> On 14/09/2023 15:10, Jani Nikula wrote:
>>> The EDID returned by drm_bridge_get_edid() needs to be freed.
>>>
>>> Fixes: 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")
>>> Cc: Neil Armstrong <narmstrong@baylibre.com>
>>> Cc: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
>>> Cc: Neil Armstrong <neil.armstrong@linaro.org>
>>> Cc: Kevin Hilman <khilman@baylibre.com>
>>> Cc: Jerome Brunet <jbrunet@baylibre.com>
>>> Cc: dri-devel@lists.freedesktop.org
>>> Cc: linux-amlogic@lists.infradead.org
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> Cc: <stable@vger.kernel.org> # v5.17+
>>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>>>
>>> ---
>>>
>>> UNTESTED
>>> ---
>>>    drivers/gpu/drm/meson/meson_encoder_hdmi.c | 2 ++
>>>    1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>>> index 9913971fa5d2..25ea76558690 100644
>>> --- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>>> +++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
>>> @@ -334,6 +334,8 @@ static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge,
>>>    			return;
>>>    
>>>    		cec_notifier_set_phys_addr_from_edid(encoder_hdmi->cec_notifier, edid);
>>> +
>>> +		kfree(edid);
>>>    	} else
>>>    		cec_notifier_phys_addr_invalidate(encoder_hdmi->cec_notifier);
>>>    }
>>
>> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> 
> Thanks. I don't seem to have a toolchain to get this to build... would
> you mind applying this, please?

Sure I'll handle this.

Thanks,
Neil

> 
> BR,
> Jani.
> 
>
Neil Armstrong Sept. 20, 2023, 1:46 p.m. UTC | #4
Hi,

On Thu, 14 Sep 2023 16:10:15 +0300, Jani Nikula wrote:
> The EDID returned by drm_bridge_get_edid() needs to be freed.
> 
> 

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-fixes)

[1/1] drm/meson: fix memory leak on ->hpd_notify callback
      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=099f0af9d98231bb74956ce92508e87cbcb896be
Jani Nikula Sept. 20, 2023, 4:31 p.m. UTC | #5
On Wed, 20 Sep 2023, Neil Armstrong <neil.armstrong@linaro.org> wrote:
> Hi,
>
> On Thu, 14 Sep 2023 16:10:15 +0300, Jani Nikula wrote:
>> The EDID returned by drm_bridge_get_edid() needs to be freed.
>> 
>> 
>
> Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-fixes)
>
> [1/1] drm/meson: fix memory leak on ->hpd_notify callback
>       https://cgit.freedesktop.org/drm/drm-misc/commit/?id=099f0af9d98231bb74956ce92508e87cbcb896be

Thanks,
Jani.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/meson/meson_encoder_hdmi.c b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
index 9913971fa5d2..25ea76558690 100644
--- a/drivers/gpu/drm/meson/meson_encoder_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_hdmi.c
@@ -334,6 +334,8 @@  static void meson_encoder_hdmi_hpd_notify(struct drm_bridge *bridge,
 			return;
 
 		cec_notifier_set_phys_addr_from_edid(encoder_hdmi->cec_notifier, edid);
+
+		kfree(edid);
 	} else
 		cec_notifier_phys_addr_invalidate(encoder_hdmi->cec_notifier);
 }