[bug report] drm/amd/display: Fix ineffective setting of max bpc property
Dan Carpenter
dan.carpenter at linaro.org
Sun Jul 14 00:51:54 UTC 2024
Hello Stylon Wang,
Commit fa7041d9d2fc ("drm/amd/display: Fix ineffective setting of max
bpc property") from Jun 12, 2020 (linux-next), leads to the following
Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:7201 create_validate_stream_for_sink()
error: we previously assumed 'dm_state' could be null (see line 7194)
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
7185 struct dc_stream_state *
7186 create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
7187 const struct drm_display_mode *drm_mode,
7188 const struct dm_connector_state *dm_state,
7189 const struct dc_stream_state *old_stream)
7190 {
7191 struct drm_connector *connector = &aconnector->base;
7192 struct amdgpu_device *adev = drm_to_adev(connector->dev);
7193 struct dc_stream_state *stream;
7194 const struct drm_connector_state *drm_state = dm_state ? &dm_state->base : NULL;
^^^^^^^^
^^^^^^^^^
This used check connector->state but then we changed it to dm_state instead
7195 int requested_bpc = drm_state ? drm_state->max_requested_bpc : 8;
7196 enum dc_status dc_result = DC_OK;
7197
7198 do {
7199 stream = create_stream_for_sink(connector, drm_mode,
7200 dm_state, old_stream,
^^^^^^^^
But dm_state is dereferenced on the next line without checking. (Presumably
the NULL check can be removed).
--> 7201 requested_bpc);
7202 if (stream == NULL) {
7203 DRM_ERROR("Failed to create stream for sink!\n");
7204 break;
7205 }
7206
7207 if (aconnector->base.connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
regards,
dan carpenter
More information about the amd-gfx
mailing list