if (i == dc->res_pool->pipe_count)
                return;
 
+/*
+ * In case of a dangling plane, setting this to NULL unconditionally
+ * causes failures during reset hw ctx where, if stream is NULL,
+ * it is expected that the pipe_ctx pointers to pipes and plane are NULL.
+ */
        pipe_ctx->stream = NULL;
        DC_LOG_DEBUG("Reset back end for pipe %d, tg:%d\n",
                                        pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst);
 
        int prev_odm_offset = 0;
        int next_odm_width = 0;
        int next_odm_offset = 0;
+       struct pipe_ctx *next_odm_pipe = NULL;
+       struct pipe_ctx *prev_odm_pipe = NULL;
 
        int x_pos = pos_cpy.x;
        int y_pos = pos_cpy.y;
                }
        }
 
+
        /**
         * DCN4 moved cursor composition after Scaler, so in HW it is in
         * recout space and for HW Cursor position programming need to
         * next/prev_odm_offset is to account for scaled modes that have underscan
         */
        if (odm_combine_on) {
-               struct pipe_ctx *next_odm_pipe = pipe_ctx->next_odm_pipe;
-               struct pipe_ctx *prev_odm_pipe = pipe_ctx->prev_odm_pipe;
+               next_odm_pipe = pipe_ctx->next_odm_pipe;
+               prev_odm_pipe = pipe_ctx->prev_odm_pipe;
 
                while (next_odm_pipe != NULL) {
                        next_odm_width += next_odm_pipe->plane_res.scl_data.recout.width;