Hello Hawking Zhang,

Commit 3d879e81f0f9 ("drm/amdgpu: add init support for GFX11 (v2)")
from Apr 13, 2022 (linux-next), leads to the following Smatch static
checker warning:

        drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:4503 gfx_v11_0_hw_init()
        error: we previously assumed 'adev->gfx.imu.funcs' could be null (see 
line 4497)

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
    4491 static int gfx_v11_0_hw_init(void *handle)
    4492 {
    4493         int r;
    4494         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
    4495 
    4496         if (adev->firmware.load_type == 
AMDGPU_FW_LOAD_RLC_BACKDOOR_AUTO) {
    4497                 if (adev->gfx.imu.funcs) {
                             ^^^^^^^^^^^^^^^^^^^
Check for NULL

    4498                         /* RLC autoload sequence 1: Program rlc ram */
    4499                         if (adev->gfx.imu.funcs->program_rlc_ram)
    4500                                 
adev->gfx.imu.funcs->program_rlc_ram(adev);
    4501                 }
    4502                 /* rlc autoload firmware */
--> 4503                 r = gfx_v11_0_rlc_backdoor_autoload_enable(adev);
                                                                    ^^^^
Unchecked dereference inside the function.  (Probably just delete the
NULL check?)

    4504                 if (r)
    4505                         return r;
    4506         } else {

regards,
dan carpenter

Reply via email to