drm/vc4: Fix crash if we have to unbind HDMI.
authorEric Anholt <eric@anholt.net>
Mon, 13 Nov 2017 22:23:48 +0000 (14:23 -0800)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:57:32 +0000 (15:57 +0100)
We need the card to unregister before the codec that the card
references.

Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/vc4/vc4_hdmi.c

index 48ded8cf45fcdfde20d4212d1a81c8d177495b5c..77addfb22953040967f90e67cfc6388878ccaa06 100644 (file)
@@ -1081,7 +1081,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)
         * snd_soc_card_get_drvdata() if needed.
         */
        snd_soc_card_set_drvdata(card, hdmi);
-       ret = devm_snd_soc_register_card(dev, card);
+       ret = snd_soc_register_card(card);
        if (ret) {
                dev_err(dev, "Could not register sound card: %d\n", ret);
                goto unregister_codec;
@@ -1098,13 +1098,16 @@ unregister_codec:
 static void vc4_hdmi_audio_cleanup(struct vc4_hdmi *hdmi)
 {
        struct device *dev = &hdmi->pdev->dev;
+       struct snd_soc_card *card = &hdmi->audio.card;
 
        /*
         * If drvdata is not set this means the audio card was not
         * registered, just skip codec unregistration in this case.
         */
-       if (dev_get_drvdata(dev))
+       if (dev_get_drvdata(dev)) {
+               snd_soc_unregister_card(card);
                snd_soc_unregister_codec(dev);
+       }
 }
 
 static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)