]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: mgb4: Fix double debugfs remove
authorMartin Tůma <martin.tuma@digiteqautomotive.com>
Tue, 21 May 2024 16:22:54 +0000 (18:22 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 27 May 2024 09:33:56 +0000 (11:33 +0200)
Fixes an error where debugfs_remove_recursive() is called first on a parent
directory and then again on a child which causes a kernel panic.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: 0ab13674a9bd ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver")
Cc: <stable@vger.kernel.org>
[hverkuil: added Fixes/Cc tags]

drivers/media/pci/mgb4/mgb4_core.c

index 60498a5abebf3bea3699fe596cdfeaca11970e33..ab4f07e2e56030fa7891f26a5f909f8edb884315 100644 (file)
@@ -642,9 +642,6 @@ static void mgb4_remove(struct pci_dev *pdev)
        struct mgb4_dev *mgbdev = pci_get_drvdata(pdev);
        int i;
 
-#ifdef CONFIG_DEBUG_FS
-       debugfs_remove_recursive(mgbdev->debugfs);
-#endif
 #if IS_REACHABLE(CONFIG_HWMON)
        hwmon_device_unregister(mgbdev->hwmon_dev);
 #endif
@@ -659,6 +656,10 @@ static void mgb4_remove(struct pci_dev *pdev)
                if (mgbdev->vin[i])
                        mgb4_vin_free(mgbdev->vin[i]);
 
+#ifdef CONFIG_DEBUG_FS
+       debugfs_remove_recursive(mgbdev->debugfs);
+#endif
+
        device_remove_groups(&mgbdev->pdev->dev, mgb4_pci_groups);
        free_spi(mgbdev);
        free_i2c(mgbdev);