Re: [PATCH] drm/amd/pm: check return value of amdgpu_irq_add_id()

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

 



Am 01.10.24 um 12:57 schrieb Igor Artemiev:
amdgpu_irq_ad_id() may fail and the irq handlers will not be registered.
This patch adds error code check.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Signed-off-by: Igor Artemiev <Igor.A.Artemiev@xxxxxxx>
---
  .../drm/amd/pm/powerplay/hwmgr/smu_helper.c   | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
index 79a566f3564a..109df1039d5c 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu_helper.c
@@ -647,28 +647,41 @@ int smu9_register_irq_handlers(struct pp_hwmgr *hwmgr)
  {
  	struct amdgpu_irq_src *source =
  		kzalloc(sizeof(struct amdgpu_irq_src), GFP_KERNEL);
+	int ret;
if (!source)
  		return -ENOMEM;
source->funcs = &smu9_irq_funcs; - amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),
+	ret = amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),

The cast to struct amdgpu_device should probably be removed.

  			SOC15_IH_CLIENTID_THM,
  			THM_9_0__SRCID__THM_DIG_THERM_L2H,
  			source);

And the parameters indented to the new opening of the (.

Regards,
Christian.

-	amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),
+	if (ret)
+		goto err;
+
+	ret = amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),
  			SOC15_IH_CLIENTID_THM,
  			THM_9_0__SRCID__THM_DIG_THERM_H2L,
  			source);
+	if (ret)
+		goto err;
/* Register CTF(GPIO_19) interrupt */
-	amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),
+	ret = amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev),
  			SOC15_IH_CLIENTID_ROM_SMUIO,
  			SMUIO_9_0__SRCID__SMUIO_GPIO19,
  			source);
+	if (ret)
+		goto err;
return 0;
+
+err:
+	kfree(source);
+
+	return ret;
  }
void *smu_atom_get_data_table(void *dev, uint32_t table, uint16_t *size,




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux