⬢ DragonFlyBSD Kernel Audit
DF-4579 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/drm_pci.c
+++ b/sys/dev/drm/drm_pci.c
@@ -351,9 +351,12 @@
 #if 0
 	drm_pci_agp_destroy(dev);
 	pci_disable_device(pdev);
-err_free:
-	drm_dev_unref(dev);
 #endif
+	/* upstream error unwind: drop the reference taken by drm_dev_alloc.
+	 * Without this every failed drm_dev_register (e.g. radeon fatal GPU
+	 * init) leaks struct drm_device. drm_dev_unref() handles the
+	 * minors-unregistered state created by drm_dev_register's err path. */
+	drm_dev_unref(dev);
 	return ret;
 }
 EXPORT_SYMBOL(drm_get_pci_dev);