Skip to contentSkip to conversation

media: mgb4: Fix double debugfs remove

git:media_stage/master Hans Verkuil 1 participant 1 message Jun 10, 2024

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

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: mgb4: Fix double debugfs remove
Author:  Martin Tůma <[email protected]>
Date:    Tue May 21 18:22:54 2024 +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.

Fixes 0ab13674a9bd ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver")
[hverkuil: added Fixes/Cc tags]
 drivers/media/pci/mgb4/mgb4_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

---

drivers/media/pci/mgb4/mgb4_core.c +4 -3
index 60498a5abebf..ab4f07e2e560 100644
@@ -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);