⬢ DragonFlyBSD Kernel Audit
DF-2871 / fix.diff
← back to finding ↓ download raw
--- sys/kern/subr_taskqueue.c	2026-06-29 12:51:19.000000000 +0000
+++ /tmp/opencode/v26/fixtree/sys/kern/subr_taskqueue.c	2026-10-24 16:33:07.793715510 +0000
@@ -60,6 +60,7 @@
 	int			tq_tcount;
 	int			tq_flags;
 	int			tq_callouts;
+	int			tq_first_error;	/* DF-2871 */
 };
 
 #define	TQ_FLAGS_ACTIVE		(1 << 0)
@@ -592,9 +593,16 @@
 					    "%s_%d", ktname, i);
 		}
 		if (error) {
+			/*
+			 * DF-2871: track the first failure; if no thread
+			 * could be created the queue is unrunnable and
+			 * every future drain would hang forever.
+			 */
 			kprintf("%s: lwkt_create(%s): error %d", __func__,
 			    ktname, error);
 			tq->tq_threads[i] = NULL;
+			if (tq->tq_first_error == 0)
+				tq->tq_first_error = error;
 		} else {
 			td = tq->tq_threads[i];
 			lwkt_setpri_initial(td, pri);
@@ -603,6 +611,12 @@
 		}
 	}
 
+	if (tq->tq_tcount == 0 && tq->tq_first_error) {
+		kfree(tq->tq_threads, M_TASKQUEUE);
+		tq->tq_threads = NULL;
+		return (tq->tq_first_error);
+	}
+
 	return 0;
 }