[bug report] drm/amd/display: Expose HDR output metadata for supported connectors

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

 



Hello Nicholas Kazlauskas,

Commit 88694af9e4d1 ("drm/amd/display: Expose HDR output metadata for
supported connectors") from May 28, 2019 (linux-next), leads to the
following Smatch static checker warning:

	drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:10751 dm_update_crtc_state()
	warn: 'drm_new_conn_state' can also be NULL

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
    10672 static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
    10673                          struct drm_atomic_state *state,
    10674                          struct drm_crtc *crtc,
    10675                          struct drm_crtc_state *old_crtc_state,
    10676                          struct drm_crtc_state *new_crtc_state,
    10677                          bool enable,
    10678                          bool *lock_and_validation_needed)
    10679 {
    10680         struct dm_atomic_state *dm_state = NULL;
    10681         struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
    10682         struct dc_stream_state *new_stream;
    10683         int ret = 0;
    10684 
    10685         /*
    10686          * TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set
    10687          * update changed items
    10688          */
    10689         struct amdgpu_crtc *acrtc = NULL;
    10690         struct drm_connector *connector = NULL;
    10691         struct amdgpu_dm_connector *aconnector = NULL;
    10692         struct drm_connector_state *drm_new_conn_state = NULL, *drm_old_conn_state = NULL;
    10693         struct dm_connector_state *dm_new_conn_state = NULL, *dm_old_conn_state = NULL;
    10694 
    10695         new_stream = NULL;
    10696 
    10697         dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
    10698         dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
    10699         acrtc = to_amdgpu_crtc(crtc);
    10700         connector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
    10701         if (connector)
    10702                 aconnector = to_amdgpu_dm_connector(connector);
    10703 
    10704         /* TODO This hack should go away */
    10705         if (connector && enable) {
    10706                 /* Make sure fake sink is created in plug-in scenario */
    10707                 drm_new_conn_state = drm_atomic_get_new_connector_state(state,
    10708                                                                         connector);

drm_atomic_get_new_connector_state() can't return error pointers, only
NULL.

    10709                 drm_old_conn_state = drm_atomic_get_old_connector_state(state,
    10710                                                                         connector);
    10711 
    10712                 if (IS_ERR(drm_new_conn_state)) {
                                     ^^^^^^^^^^^^^^^^^^

    10713                         ret = PTR_ERR_OR_ZERO(drm_new_conn_state);

Calling PTR_ERR_OR_ZERO() doesn't make sense.  It can't be success.

    10714                         goto fail;
    10715                 }
    10716 
    10717                 dm_new_conn_state = to_dm_connector_state(drm_new_conn_state);
    10718                 dm_old_conn_state = to_dm_connector_state(drm_old_conn_state);
    10719 
    10720                 if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
    10721                         goto skip_modeset;
    10722 
    10723                 new_stream = create_validate_stream_for_sink(connector,
    10724                                                              &new_crtc_state->mode,
    10725                                                              dm_new_conn_state,
    10726                                                              dm_old_crtc_state->stream);
    10727 
    10728                 /*
    10729                  * we can have no stream on ACTION_SET if a display
    10730                  * was disconnected during S3, in this case it is not an
    10731                  * error, the OS will be updated after detection, and
    10732                  * will do the right thing on next atomic commit
    10733                  */
    10734 
    10735                 if (!new_stream) {
    10736                         DRM_DEBUG_DRIVER("%s: Failed to create new stream for crtc %d\n",
    10737                                         __func__, acrtc->base.base.id);
    10738                         ret = -ENOMEM;
    10739                         goto fail;
    10740                 }
    10741 
    10742                 /*
    10743                  * TODO: Check VSDB bits to decide whether this should
    10744                  * be enabled or not.
    10745                  */
    10746                 new_stream->triggered_crtc_reset.enabled =
    10747                         dm->force_timing_sync;
    10748 
    10749                 dm_new_crtc_state->abm_level = dm_new_conn_state->abm_level;
    10750 
--> 10751                 ret = fill_hdr_info_packet(drm_new_conn_state,
                                                     ^^^^^^^^^^^^^^^^^^
Unchecked dereference

    10752                                            &new_stream->hdr_static_metadata);
    10753                 if (ret)
    10754                         goto fail;
    10755 

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux