[radeon-alex:amd-staging-drm-next-pco 272/339] drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5137 dm_determine_update_type_for_commit() error: potential null dereference 'surface'. (kzalloc returns null)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   git://people.freedesktop.org/~agd5f/linux.git amd-staging-drm-next-pco
head:   bbab57a341c90ed6e32de8edf4e89dc5c55cddac
commit: 42b0cb5d6f8d3c641098454aabfa4eeeb935ccd2 [272/339] drm/amd/display: Build stream update and plane updates in dm

smatch warnings:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5137 dm_determine_update_type_for_commit() error: potential null dereference 'surface'.  (kzalloc returns null)
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5137 dm_determine_update_type_for_commit() error: potential null dereference 'updates'.  (kzalloc returns null)

vim +/surface +5137 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c

  5098	
  5099	
  5100		int i, j, num_plane;
  5101		struct drm_plane_state *old_plane_state, *new_plane_state;
  5102		struct dm_plane_state *new_dm_plane_state, *old_dm_plane_state;
  5103		struct drm_crtc *new_plane_crtc, *old_plane_crtc;
  5104		struct drm_plane *plane;
  5105	
  5106		struct drm_crtc *crtc;
  5107		struct drm_crtc_state *new_crtc_state, *old_crtc_state;
  5108		struct dm_crtc_state *new_dm_crtc_state, *old_dm_crtc_state;
  5109		struct dc_stream_status *status = NULL;
  5110	
  5111		struct dc_surface_update *updates = kzalloc(MAX_SURFACES * sizeof(struct dc_surface_update), GFP_KERNEL);
  5112		struct dc_plane_state *surface = kzalloc(MAX_SURFACES * sizeof(struct dc_plane_state), GFP_KERNEL);
  5113		struct dc_stream_update stream_update;
  5114		enum surface_update_type update_type = UPDATE_TYPE_FAST;
  5115	
  5116	
  5117		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
  5118			new_dm_crtc_state = to_dm_crtc_state(new_crtc_state);
  5119			old_dm_crtc_state = to_dm_crtc_state(old_crtc_state);
  5120			num_plane = 0;
  5121	
  5122			if (new_dm_crtc_state->stream) {
  5123	
  5124				for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, j) {
  5125					new_plane_crtc = new_plane_state->crtc;
  5126					old_plane_crtc = old_plane_state->crtc;
  5127					new_dm_plane_state = to_dm_plane_state(new_plane_state);
  5128					old_dm_plane_state = to_dm_plane_state(old_plane_state);
  5129	
  5130					if (plane->type == DRM_PLANE_TYPE_CURSOR)
  5131						continue;
  5132	
  5133					if (!state->allow_modeset)
  5134						continue;
  5135	
  5136					if (crtc == new_plane_crtc) {
> 5137						updates[num_plane].surface = &surface[num_plane];
  5138	
  5139						if (new_crtc_state->mode_changed) {
  5140							updates[num_plane].surface->src_rect =
  5141										new_dm_plane_state->dc_state->src_rect;
  5142							updates[num_plane].surface->dst_rect =
  5143										new_dm_plane_state->dc_state->dst_rect;
  5144							updates[num_plane].surface->rotation =
  5145										new_dm_plane_state->dc_state->rotation;
  5146							updates[num_plane].surface->in_transfer_func =
  5147										new_dm_plane_state->dc_state->in_transfer_func;
  5148							stream_update.dst = new_dm_crtc_state->stream->dst;
  5149							stream_update.src = new_dm_crtc_state->stream->src;
  5150						}
  5151	
  5152						if (new_crtc_state->color_mgmt_changed) {
  5153							updates[num_plane].gamma =
  5154									new_dm_plane_state->dc_state->gamma_correction;
  5155							updates[num_plane].in_transfer_func =
  5156									new_dm_plane_state->dc_state->in_transfer_func;
  5157							stream_update.gamut_remap =
  5158									&new_dm_crtc_state->stream->gamut_remap_matrix;
  5159							stream_update.out_transfer_func =
  5160									new_dm_crtc_state->stream->out_transfer_func;
  5161						}
  5162	
  5163						num_plane++;
  5164					}
  5165				}
  5166	
  5167				if (num_plane > 0) {
  5168					status = dc_stream_get_status(new_dm_crtc_state->stream);
  5169					update_type = dc_check_update_surfaces_for_stream(dc, updates, num_plane,
  5170											  &stream_update, status);
  5171	
  5172					if (update_type > UPDATE_TYPE_MED) {
  5173						update_type = UPDATE_TYPE_FULL;
  5174						goto ret;
  5175					}
  5176				}
  5177	
  5178			} else if (!new_dm_crtc_state->stream && old_dm_crtc_state->stream) {
  5179				update_type = UPDATE_TYPE_FULL;
  5180				goto ret;
  5181			}
  5182		}
  5183	
  5184	ret:
  5185		kfree(updates);
  5186		kfree(surface);
  5187	
  5188		return update_type;
  5189	}
  5190	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux