[PATCH] drm/display: hdmi-cec-helper: Fix adapter unregistration

Cristian Ciocaltea posted 1 patch 3 months ago
drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] drm/display: hdmi-cec-helper: Fix adapter unregistration
Posted by Cristian Ciocaltea 3 months ago
Attempting to reload a kernel module of an HDMI driver making use of the
new CEC helpers revealed a resource deallocation issue, i.e. the entries
in /dev/cec* keep growing.

Moreover, after a couple of tries the kernel crashes and the whole
system freezes:

[   47.515950] Unable to handle kernel paging request at virtual address 0020072007200778
[...]
[   47.521707] Internal error: Oops: 0000000096000004 [#1]  SMP
[...]
[   47.537597] Call trace:
[   47.537815]  klist_next+0x20/0x1b8 (P)
[   47.538152]  device_reorder_to_tail+0x74/0x120
[   47.538548]  device_reorder_to_tail+0x6c/0x120
[   47.538944]  device_pm_move_to_tail+0x78/0xd0
[   47.539334]  deferred_probe_work_func+0x9c/0x110
[   47.539747]  process_one_work+0x328/0x638
[   47.540108]  worker_thread+0x264/0x390
[   47.540445]  kthread+0x20c/0x230
[   47.540735]  ret_from_fork+0x10/0x20

Do a proper cleanup by calling cec_unregister_adapter() instead of
cec_delete_adapter() in the managed release action handler.

Fixes: 8b1a8f8b2002 ("drm/display: add CEC helpers code")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_cec_helper.c b/drivers/gpu/drm/display/drm_hdmi_cec_helper.c
index b4273c3522fa8b4996fd02107a87acefa3a45737..3651ad0f76e0c49cc7b3a8e2148dccb1f290e95a 100644
--- a/drivers/gpu/drm/display/drm_hdmi_cec_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_cec_helper.c
@@ -69,7 +69,7 @@ static void drm_connector_hdmi_cec_adapter_unregister(struct drm_device *dev, vo
 	struct drm_connector *connector = res;
 	struct drm_connector_hdmi_cec_data *data = connector->cec.data;
 
-	cec_delete_adapter(data->adapter);
+	cec_unregister_adapter(data->adapter);
 
 	if (data->funcs->uninit)
 		data->funcs->uninit(connector);

---
base-commit: 8d6c58332c7a8ba025fcfa76888b6c37dbce9633
change-id: 20250703-hdmi-cec-helper-unreg-fix-d9e71349c1f4
Re: [PATCH] drm/display: hdmi-cec-helper: Fix adapter unregistration
Posted by Dmitry Baryshkov 3 months ago
On Thu, 03 Jul 2025 23:05:45 +0300, Cristian Ciocaltea wrote:
> Attempting to reload a kernel module of an HDMI driver making use of the
> new CEC helpers revealed a resource deallocation issue, i.e. the entries
> in /dev/cec* keep growing.
> 
> Moreover, after a couple of tries the kernel crashes and the whole
> system freezes:
> 
> [...]

Applied to drm-misc-next, thanks!

[1/1] drm/display: hdmi-cec-helper: Fix adapter unregistration
      commit: 19920ab98e17af4e733ec4c69881d8ce433d3f1d

Best regards,
-- 
With best wishes
Dmitry
Re: [PATCH] drm/display: hdmi-cec-helper: Fix adapter unregistration
Posted by Dmitry Baryshkov 3 months ago
On Thu, Jul 03, 2025 at 11:05:45PM +0300, Cristian Ciocaltea wrote:
> Attempting to reload a kernel module of an HDMI driver making use of the
> new CEC helpers revealed a resource deallocation issue, i.e. the entries
> in /dev/cec* keep growing.
> 
> Moreover, after a couple of tries the kernel crashes and the whole
> system freezes:
> 
> [   47.515950] Unable to handle kernel paging request at virtual address 0020072007200778
> [...]
> [   47.521707] Internal error: Oops: 0000000096000004 [#1]  SMP
> [...]
> [   47.537597] Call trace:
> [   47.537815]  klist_next+0x20/0x1b8 (P)
> [   47.538152]  device_reorder_to_tail+0x74/0x120
> [   47.538548]  device_reorder_to_tail+0x6c/0x120
> [   47.538944]  device_pm_move_to_tail+0x78/0xd0
> [   47.539334]  deferred_probe_work_func+0x9c/0x110
> [   47.539747]  process_one_work+0x328/0x638
> [   47.540108]  worker_thread+0x264/0x390
> [   47.540445]  kthread+0x20c/0x230
> [   47.540735]  ret_from_fork+0x10/0x20
> 
> Do a proper cleanup by calling cec_unregister_adapter() instead of
> cec_delete_adapter() in the managed release action handler.
> 
> Fixes: 8b1a8f8b2002 ("drm/display: add CEC helpers code")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry