Hello Rodrigo Siqueira,

The patch 135fd1b35690: "drm/amd/display: Reduce stack size" from Jun
21, 2023 (linux-next), leads to the following Smatch static checker
warning:

        drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8785 
amdgpu_dm_atomic_commit_tail()
        error: potential null dereference 'dummy_updates'.  (kzalloc returns 
null)

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c
    8771                 status = 
dc_stream_get_status(dm_new_crtc_state->stream);
    8772 
    8773                 if (WARN_ON(!status))
    8774                         continue;
    8775 
    8776                 WARN_ON(!status->plane_count);
    8777 
    8778                 /*
    8779                  * TODO: DC refuses to perform stream updates without 
a dc_surface_update.
    8780                  * Here we create an empty update on each plane.
    8781                  * To fix this, DC should permit updating only stream 
properties.
    8782                  */
    8783                 dummy_updates = kzalloc(sizeof(struct 
dc_surface_update) * MAX_SURFACES, GFP_ATOMIC);

This needs a NULL check.

    8784                 for (j = 0; j < status->plane_count; j++)
--> 8785                         dummy_updates[j].surface = 
status->plane_states[0];
                                 ^^^^^^^^^^^^^^^^
Kaplooey!

    8786 
    8787 
    8788                 mutex_lock(&dm->dc_lock);
    8789                 dc_update_planes_and_stream(dm->dc,
    8790                                             dummy_updates,
    8791                                             status->plane_count,
    8792                                             dm_new_crtc_state->stream,
    8793                                             &stream_update);
    8794                 mutex_unlock(&dm->dc_lock);
    8795                 kfree(dummy_updates);

regards,
dan carpenter

Reply via email to