Commit fdd5ecbb authored by Alex Hung's avatar Alex Hung Committed by Alex Deucher
Browse files

drm/amd/display: Check null pointers before multiple uses



[WHAT & HOW]
Poniters, such as stream_enc and dc->bw_vbios, are null checked previously
in the same function, so Coverity warns "implies that stream_enc and
dc->bw_vbios might be null". They are used multiple times in the
subsequent code and need to be checked.

This fixes 10 FORWARD_NULL issues reported by Coverity.

Reviewed-by: default avatarRodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: default avatarJerry Zuo <jerry.zuo@amd.com>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent be1fb443
Loading
Loading
Loading
Loading
+49 −47
Original line number Diff line number Diff line
@@ -636,7 +636,8 @@ void hwss_build_fast_sequence(struct dc *dc,
	while (current_pipe) {
		current_mpc_pipe = current_pipe;
		while (current_mpc_pipe) {
			if (dc->hwss.set_flip_control_gsl && current_mpc_pipe->plane_state && current_mpc_pipe->plane_state->update_flags.raw) {
			if (current_mpc_pipe->plane_state) {
				if (dc->hwss.set_flip_control_gsl && current_mpc_pipe->plane_state->update_flags.raw) {
					block_sequence[*num_steps].params.set_flip_control_gsl_params.pipe_ctx = current_mpc_pipe;
					block_sequence[*num_steps].params.set_flip_control_gsl_params.flip_immediate = current_mpc_pipe->plane_state->flip_immediate;
					block_sequence[*num_steps].func = HUBP_SET_FLIP_CONTROL_GSL;
@@ -688,6 +689,7 @@ void hwss_build_fast_sequence(struct dc *dc,
					block_sequence[*num_steps].func = DPP_PROGRAM_BIAS_AND_SCALE;
					(*num_steps)++;
				}
			}
			if (hws->funcs.set_output_transfer_func && current_mpc_pipe->stream->update_flags.bits.out_tf) {
				block_sequence[*num_steps].params.set_output_transfer_func_params.dc = dc;
				block_sequence[*num_steps].params.set_output_transfer_func_params.pipe_ctx = current_mpc_pipe;
+7 −1
Original line number Diff line number Diff line
@@ -2284,6 +2284,9 @@ void dcn20_post_unlock_program_front_end(
		}
	}

	if (!hwseq)
		return;

	/* P-State support transitions:
	 * Natural -> FPO: 		P-State disabled in prepare, force disallow anytime is safe
	 * FPO -> Natural: 		Unforce anytime after FW disable is safe (P-State will assert naturally)
@@ -2291,7 +2294,7 @@ void dcn20_post_unlock_program_front_end(
	 * FPO -> Unsupported:	P-State disabled in prepare, unforce disallow anytime is safe
	 * FPO <-> SubVP:		Force disallow is maintained on the FPO / SubVP pipes
	 */
	if (hwseq && hwseq->funcs.update_force_pstate)
	if (hwseq->funcs.update_force_pstate)
		dc->hwseq->funcs.update_force_pstate(dc, context);

	/* Only program the MALL registers after all the main and phantom pipes
@@ -2531,6 +2534,9 @@ bool dcn20_wait_for_blank_complete(
{
	int counter;

	if (!opp)
		return false;

	for (counter = 0; counter < 1000; counter++) {
		if (!opp->funcs->dpg_is_pending(opp))
			break;
+4 −1
Original line number Diff line number Diff line
@@ -804,8 +804,11 @@ bool dp_set_test_pattern(
			break;
		}

		if (!pipe_ctx->stream)
			return false;

		if (pipe_ctx->stream_res.tg->funcs->lock_doublebuffer_enable) {
			if (pipe_ctx->stream && should_use_dmub_lock(pipe_ctx->stream->link)) {
			if (should_use_dmub_lock(pipe_ctx->stream->link)) {
				union dmub_hw_lock_flags hw_locks = { 0 };
				struct dmub_hw_lock_inst_flags inst_flags = { 0 };

+4 −1
Original line number Diff line number Diff line
@@ -74,7 +74,10 @@ void reset_dio_stream_encoder(struct pipe_ctx *pipe_ctx)
	struct link_encoder *link_enc = link_enc_cfg_get_link_enc(pipe_ctx->stream->link);
	struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;

	if (stream_enc && stream_enc->funcs->disable_fifo)
	if (!stream_enc)
		return;

	if (stream_enc->funcs->disable_fifo)
		stream_enc->funcs->disable_fifo(stream_enc);
	if (stream_enc->funcs->set_input_mode)
		stream_enc->funcs->set_input_mode(stream_enc, 0);
+4 −1
Original line number Diff line number Diff line
@@ -1067,7 +1067,10 @@ static void bw_calcs_data_update_from_pplib(struct dc *dc)
	struct dm_pp_clock_levels clks = {0};
	int memory_type_multiplier = MEMORY_TYPE_MULTIPLIER_CZ;

	if (dc->bw_vbios && dc->bw_vbios->memory_type == bw_def_hbm)
	if (!dc->bw_vbios)
		return;

	if (dc->bw_vbios->memory_type == bw_def_hbm)
		memory_type_multiplier = MEMORY_TYPE_HBM;

	/*do system clock  TODO PPLIB: after PPLIB implement,
Loading