RE: [bug report] drm/amdgpu: add init support for GFX11 (v2)

2024-06-21 Thread Zhang, Hawking
[AMD Official Use Only - AMD Internal Distribution Only]

Hi,

The fix is sent out for code review.

Regards,
Hawking

-Original Message-
From: Dan Carpenter 
Sent: Saturday, June 15, 2024 01:33
To: Zhang, Hawking 
Cc: amd-gfx@lists.freedesktop.org; SHANMUGAM, SRINIVASAN 

Subject: [bug report] drm/amdgpu: add init support for GFX11 (v2)

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


[bug report] drm/amdgpu: add init support for GFX11 (v2)

2024-06-17 Thread Dan Carpenter
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