From nobody Thu Nov 28 13:44:18 2024 Received: from tretyak2.mcst.ru (tretyak2.mcst.ru [212.5.119.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 309931A08B2 for ; Tue, 1 Oct 2024 11:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.5.119.215 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727780708; cv=none; b=Hk9TUFYkjPcz6icbCoU1AqpfmeVR99wJYaAX0VcifuCsjkv1WxX1wpNjBiyx6vraB5onVd+Oq1/zLYB7evJb/+R9t4EXsOUkqwOjrNJDcHD4AMhCz3APP5J7Mk631f88S/4UzAeehxYHlHJIqtJm7jlF7bIMixhZjlKku5ds1EQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727780708; c=relaxed/simple; bh=+rHmXUJz9yFvw6S5U3VrCkjI9zxfOHt3F8VTxWbRo1s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=e4rn6kASqcOQorDRED4Sym8iWCBxJTBWNKOMNLvF1ivhgRVRSPOKA0/wOx+LRydU2bb9646h917dmRjsfzGq2cqfctsE8VT9LmkyCACMVofQIlOP2Jy2NZTXmPhSU3brXlORF3C4fORgC/80dWzT09FOoK9G8SDbQsrkyTY5VBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mcst.ru; spf=pass smtp.mailfrom=mcst.ru; arc=none smtp.client-ip=212.5.119.215 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mcst.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mcst.ru Received: from tretyak2.mcst.ru (localhost [127.0.0.1]) by tretyak2.mcst.ru (Postfix) with ESMTP id F3FF5102392; Tue, 1 Oct 2024 14:05:00 +0300 (MSK) Received: from frog.lab.sun.mcst.ru (frog.lab.sun.mcst.ru [176.16.4.50]) by tretyak2.mcst.ru (Postfix) with ESMTP id EAC41101765; Tue, 1 Oct 2024 14:04:10 +0300 (MSK) Received: from artemiev-i.lab.sun.mcst.ru (avior-1 [192.168.63.223]) by frog.lab.sun.mcst.ru (8.13.4/8.12.11) with ESMTP id 491B4AwQ005662; Tue, 1 Oct 2024 14:04:10 +0300 From: Igor Artemiev To: Alex Deucher Cc: Igor Artemiev , =?UTF-8?q?Christian=20K=C3=B6nig?= , Xinhui Pan , David Airlie , Kenneth Feng , Simona Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] drm/amd/pm: check return value of amdgpu_irq_add_id() Date: Tue, 1 Oct 2024 13:57:27 +0300 Message-Id: <20241001105727.1582368-1-Igor.A.Artemiev@mcst.ru> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Anti-Virus: Kaspersky Anti-Virus for Linux Mail Server 5.6.39/RELEASE, bases: 20111107 #2745587, check: 20241001 notchecked X-AV-Checked: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" 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 --- .../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 =3D kzalloc(sizeof(struct amdgpu_irq_src), GFP_KERNEL); + int ret; =20 if (!source) return -ENOMEM; =20 source->funcs =3D &smu9_irq_funcs; =20 - amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), + ret =3D amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), SOC15_IH_CLIENTID_THM, THM_9_0__SRCID__THM_DIG_THERM_L2H, source); - amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), + if (ret) + goto err; + + ret =3D 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; =20 /* Register CTF(GPIO_19) interrupt */ - amdgpu_irq_add_id((struct amdgpu_device *)(hwmgr->adev), + ret =3D 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; =20 return 0; + +err: + kfree(source); + + return ret; } =20 void *smu_atom_get_data_table(void *dev, uint32_t table, uint16_t *size, --=20 2.39.2