⬢ DragonFlyBSD Kernel Audit
DF-4353 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/display/dc/dce110/dce110_resource.c
+++ b/sys/dev/drm/amd/display/dc/dce110/dce110_resource.c
@@ -1391,6 +1391,12 @@
 	return true;
 
 res_create_fail:
+	/*
+	 * DF-4353: the compressor created above lives on dc, not in the
+	 * pool - destruct() never frees it.
+	 */
+	if (dc->fbc_compressor != NULL)
+		dce110_compressor_destroy(&dc->fbc_compressor);
 	destruct(pool);
 	return false;
 }
@@ -1410,5 +1416,11 @@
 		return &pool->base;
 
 	BREAK_TO_DEBUGGER();
+	kfree(pool);	/*
+			 * DF-4353 (DF-4318 twin): construct() already ran
+			 * destruct(pool) on its failure arm; the pool
+			 * allocation itself used to be leaked on every
+			 * failed pool build.
+			 */
 	return NULL;
 }