drm/vc4: hdmi: Switch to device-managed ALSA initialization
authorMaxime Ripard <maxime@cerno.tech>
Mon, 11 Jul 2022 17:39:11 +0000 (19:39 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 13 Jul 2022 08:46:10 +0000 (10:46 +0200)
commit59f9d46af43c884b92f690934263196387437c7e
tree81ea69dc7f00c2383a280c87148d2d72a6a0a8a3
parent19d094c3a17d228381d4f1a25158a7b91b0e294f
drm/vc4: hdmi: Switch to device-managed ALSA initialization

The current code to unregister our ALSA device needs to be undone manually
when we remove the HDMI driver.

Since ALSA doesn't seem to support any mechanism to defer freeing something
until the last user of the ALSA device is gone, we can either use a
device-managed or a DRM-managed action.

The consistent way would be to use a DRM-managed one, just like pretty much
any framework-facing structure should be doing. However, ALSA does a lot of
allocation and registration using device-managed calls. Thus, if we're
going that way, by the time the DRM-managed action would run all of those
allocation would have been freed and we would end up with a use-after-free.

Thus, let's do a device-managed action. It's been tested with KASAN enabled
and doesn't seem to trigger any issue, so it's as good as anything.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220711173939.1132294-42-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_hdmi.c