⬢ DragonFlyBSD Kernel Audit
DF-3988 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/display/dc/core/dc_link_dp.c
+++ b/sys/dev/drm/amd/display/dc/core/dc_link_dp.c
@@ -2603,7 +2603,13 @@
 	memset(&training_pattern, 0, sizeof(training_pattern));
 
 	for (i = 0; i < MAX_PIPES; i++) {
-		if (pipes[i].stream->sink->link == link) {
+		/* DF-3988: pipe_ctx[].stream is NULL for inactive pipes
+		 * (after boot with no commit, or holes left by unplug);
+		 * automated-test requests arrive without any stream on
+		 * the tested link, so NULL-check before dereferencing. */
+		if (pipes[i].stream != NULL &&
+				pipes[i].stream->sink != NULL &&
+				pipes[i].stream->sink->link == link) {
 			pipe_ctx = &pipes[i];
 			break;
 		}
@@ -2650,7 +2656,11 @@
 			 * MuteAudioEndpoint(pPathMode->pDisplayPath, true);
 			 */
 			/* Blank stream */
-			pipes->stream_res.stream_enc->funcs->dp_blank(pipe_ctx->stream_res.stream_enc);
+			/* DF-3988: blank the MATCHED pipe (pipes[0] may be
+			 * an inactive hole). */
+			if (pipe_ctx->stream_res.stream_enc != NULL)
+				pipe_ctx->stream_res.stream_enc->funcs->dp_blank(
+					pipe_ctx->stream_res.stream_enc);
 		}
 
 		dp_set_hw_test_pattern(link, test_pattern,