Skip to contentSkip to conversation

drm/vc4: hdmi: Unregister codec device on unbind

PATCH Applied Maxime Ripard 2 participants 5 messages Jan 27, 2022 – Feb 17, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vc4: hdmi: Unregister codec device on unbind

On bind we will register the HDMI codec device but we don't unregister it on unbind, leading to a device leakage. Unregister our device at unbind.

---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++++++
 drivers/gpu/drm/vc4/vc4_hdmi.h | 1 +
 2 files changed, 9 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +8 -0
index 502d5bea5f61..395a9e9c1e5a 100644
@@ -1746,6 +1746,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
 		dev_err(dev, "Couldn't register the HDMI codec: %ld\n", PTR_ERR(codec_pdev));
 		return PTR_ERR(codec_pdev);
 	}
+	vc4_hdmi->audio.codec_pdev = codec_pdev;
 
 	dai_link->cpus		= &vc4_hdmi->audio.cpu;
 	dai_link->codecs	= &vc4_hdmi->audio.codec;
@@ -1785,6 +1786,12 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
 
 }
 
+static void vc4_hdmi_audio_exit(struct vc4_hdmi *vc4_hdmi)
+{
+	platform_device_unregister(vc4_hdmi->audio.codec_pdev);
+	vc4_hdmi->audio.codec_pdev = NULL;
+}
+
 static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
 {
 	struct vc4_hdmi *vc4_hdmi = priv;
@@ -2689,6 +2696,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,
 	kfree(vc4_hdmi->hdmi_regset.regs);
 	kfree(vc4_hdmi->hd_regset.regs);
 
+	vc4_hdmi_audio_exit(vc4_hdmi);
 	vc4_hdmi_cec_exit(vc4_hdmi);
 	vc4_hdmi_hotplug_exit(vc4_hdmi);
 	vc4_hdmi_connector_destroy(&vc4_hdmi->connector);
drivers/gpu/drm/vc4/vc4_hdmi.h +1 -0
index db53500a8435..275c4674d50f 100644
@@ -113,6 +113,7 @@ struct vc4_hdmi_audio {
 	struct snd_soc_dai_link_component platform;
 	struct snd_dmaengine_dai_dma_data dma_data;
 	struct hdmi_audio_infoframe infoframe;
+	struct platform_device *codec_pdev;
 	bool streaming;
 };
 
Signature · 1 line
2.34.1
author Applied
#1 lore raw

Re: (subset) [PATCH] drm/vc4: hdmi: Unregister codec device on unbind

Quoted 5 lines · Maxime Ripard

On bind we will register the HDMI codec device but we don't unregister it on unbind, leading to a device leakage. Unregister our device at unbind.

Applied to drm/drm-misc (drm-misc-fixes).

Thanks!
Maxime

#2 lore raw

Re: (subset) [PATCH] drm/vc4: hdmi: Unregister codec device on unbind

Quoted 8 lines · Maxime Ripard
Quoted 5 lines · Maxime Ripard

On bind we will register the HDMI codec device but we don't unregister it on unbind, leading to a device leakage. Unregister our device at unbind.

Applied to drm/drm-misc (drm-misc-fixes).

This one hasn't been reviewed yet, so I dropped it for now

Maxime

Reviewed-by on v1 1/1
#3 lore raw
In reply to Maxime Ripard

Hello Maxime,

Quoted 6 lines · Maxime Ripard

On bind we will register the HDMI codec device but we don't unregister it on unbind, leading to a device leakage. Unregister our device at unbind.

---

Patch looks good to me.

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
author Applied
#4 lore raw

Re: (subset) [PATCH] drm/vc4: hdmi: Unregister codec device on unbind

In reply to Maxime Ripard
Quoted 5 lines · Maxime Ripard

On bind we will register the HDMI codec device but we don't unregister it on unbind, leading to a device leakage. Unregister our device at unbind.

Applied to drm/drm-misc (drm-misc-fixes).

Thanks!
Maxime