From: Zhang Boyang <zhangboyang.id@gmail.com> To: "Andrey Grodzovsky" <andrey.grodzovsky@amd.com>, "Christian König" <christian.koenig@amd.com>, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Cc: "David C . Rankin" <drankinatty@suddenlinkmail.com>, Steven J Abner <pheonix.sja@att.net>, Zhang Boyang <zhangboyang.id@gmail.com> Subject: [RFC PATCH 1/1] drm/amdgpu: Fix null-ptr-deref in amdgpu_device_fini_sw() Date: Sat, 1 Oct 2022 05:41:10 +0800 [thread overview] Message-ID: <20220930214110.1074226-2-zhangboyang.id@gmail.com> (raw) In-Reply-To: <20220930214110.1074226-1-zhangboyang.id@gmail.com> After amdgpu_device_init() failed, adev->reset_domain may be NULL. Thus subsequent call to amdgpu_device_fini_sw() may result in null-ptr-deref. This patch fixes the problem by adding a NULL pointer check around the code of releasing adev->reset_domain in amdgpu_device_fini_sw(). Fixes: cfbb6b004744 ("drm/amdgpu: Rework reset domain to be refcounted.") Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com> Link: https://lore.kernel.org/lkml/a8bce489-8ccc-aa95-3de6-f854e03ad557@suddenlinkmail.com/ Link: https://lore.kernel.org/lkml/AT9WHR.3Z1T3VI9A2AQ3@att.net/ --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index be7aff2d4a57..204daad06b32 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4021,8 +4021,10 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) if (adev->mman.discovery_bin) amdgpu_discovery_fini(adev); - amdgpu_reset_put_reset_domain(adev->reset_domain); - adev->reset_domain = NULL; + if (adev->reset_domain) { + amdgpu_reset_put_reset_domain(adev->reset_domain); + adev->reset_domain = NULL; + } kfree(adev->pci_state); -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Zhang Boyang <zhangboyang.id@gmail.com> To: "Andrey Grodzovsky" <andrey.grodzovsky@amd.com>, "Christian König" <christian.koenig@amd.com>, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Cc: Steven J Abner <pheonix.sja@att.net>, "David C . Rankin" <drankinatty@suddenlinkmail.com>, Zhang Boyang <zhangboyang.id@gmail.com> Subject: [RFC PATCH 1/1] drm/amdgpu: Fix null-ptr-deref in amdgpu_device_fini_sw() Date: Sat, 1 Oct 2022 05:41:10 +0800 [thread overview] Message-ID: <20220930214110.1074226-2-zhangboyang.id@gmail.com> (raw) In-Reply-To: <20220930214110.1074226-1-zhangboyang.id@gmail.com> After amdgpu_device_init() failed, adev->reset_domain may be NULL. Thus subsequent call to amdgpu_device_fini_sw() may result in null-ptr-deref. This patch fixes the problem by adding a NULL pointer check around the code of releasing adev->reset_domain in amdgpu_device_fini_sw(). Fixes: cfbb6b004744 ("drm/amdgpu: Rework reset domain to be refcounted.") Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com> Link: https://lore.kernel.org/lkml/a8bce489-8ccc-aa95-3de6-f854e03ad557@suddenlinkmail.com/ Link: https://lore.kernel.org/lkml/AT9WHR.3Z1T3VI9A2AQ3@att.net/ --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index be7aff2d4a57..204daad06b32 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4021,8 +4021,10 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) if (adev->mman.discovery_bin) amdgpu_discovery_fini(adev); - amdgpu_reset_put_reset_domain(adev->reset_domain); - adev->reset_domain = NULL; + if (adev->reset_domain) { + amdgpu_reset_put_reset_domain(adev->reset_domain); + adev->reset_domain = NULL; + } kfree(adev->pci_state); -- 2.30.2
next prev parent reply other threads:[~2022-09-30 21:41 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-30 21:41 [RFC PATCH 0/1] drm/amdgpu: Fix NULL-deref in amdgpu_device_fini_sw() Zhang Boyang 2022-09-30 21:41 ` Zhang Boyang 2022-09-30 21:41 ` Zhang Boyang [this message] 2022-09-30 21:41 ` [RFC PATCH 1/1] drm/amdgpu: Fix null-ptr-deref " Zhang Boyang 2022-09-30 22:38 ` Steven J Abner 2022-09-30 22:38 ` Steven J Abner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220930214110.1074226-2-zhangboyang.id@gmail.com \ --to=zhangboyang.id@gmail.com \ --cc=amd-gfx@lists.freedesktop.org \ --cc=andrey.grodzovsky@amd.com \ --cc=christian.koenig@amd.com \ --cc=drankinatty@suddenlinkmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=pheonix.sja@att.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.