Skip to content

Commit ee22082

Browse files
mripardgregkh
authored andcommitted
drm/vc4: hdmi: Unregister codec device on unbind
[ Upstream commit e40945a ] 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. Signed-off-by: Maxime Ripard <maxime@cerno.tech> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220127111452.222002-1-maxime@cerno.tech Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5bef4e5 commit ee22082

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
15221522
dev_err(dev, "Couldn't register the HDMI codec: %ld\n", PTR_ERR(codec_pdev));
15231523
return PTR_ERR(codec_pdev);
15241524
}
1525+
vc4_hdmi->audio.codec_pdev = codec_pdev;
15251526

15261527
dai_link->cpus = &vc4_hdmi->audio.cpu;
15271528
dai_link->codecs = &vc4_hdmi->audio.codec;
@@ -1561,6 +1562,12 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
15611562

15621563
}
15631564

1565+
static void vc4_hdmi_audio_exit(struct vc4_hdmi *vc4_hdmi)
1566+
{
1567+
platform_device_unregister(vc4_hdmi->audio.codec_pdev);
1568+
vc4_hdmi->audio.codec_pdev = NULL;
1569+
}
1570+
15641571
static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
15651572
{
15661573
struct vc4_hdmi *vc4_hdmi = priv;
@@ -2298,6 +2305,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,
22982305
kfree(vc4_hdmi->hdmi_regset.regs);
22992306
kfree(vc4_hdmi->hd_regset.regs);
23002307

2308+
vc4_hdmi_audio_exit(vc4_hdmi);
23012309
vc4_hdmi_cec_exit(vc4_hdmi);
23022310
vc4_hdmi_hotplug_exit(vc4_hdmi);
23032311
vc4_hdmi_connector_destroy(&vc4_hdmi->connector);

drivers/gpu/drm/vc4/vc4_hdmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct vc4_hdmi_audio {
113113
struct snd_soc_dai_link_component platform;
114114
struct snd_dmaengine_dai_dma_data dma_data;
115115
struct hdmi_audio_infoframe infoframe;
116+
struct platform_device *codec_pdev;
116117
bool streaming;
117118
};
118119

0 commit comments

Comments
 (0)