* [PATCH] drm/amdkfd: fix potential null pointer dereference on pointer peer_dev
@ 2019-06-29 13:31 Colin King
2019-07-02 15:29 ` Liu, Shaoyun
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-06-29 13:31 UTC (permalink / raw)
To: Oded Gabbay, Alex Deucher, Christian König, David Zhou,
David Airlie, Daniel Vetter, dri-devel, amd-gfx
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The call to kfd_topology_device_by_proximity_domain can return a NULL
pointer so add a null pointer check on peer_dev to the existing null
pointer check on peer_dev->gpu to avoid any potential null pointer
dereferences.
Addresses-Coverity: ("Dereference on null return value")
Fixes: ae9a25aea7f3 ("drm/amdkfd: Generate xGMI direct iolink")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 4e3fc284f6ac..cb6b46cfa6c2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -1293,7 +1293,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
if (kdev->hive_id) {
for (nid = 0; nid < proximity_domain; ++nid) {
peer_dev = kfd_topology_device_by_proximity_domain(nid);
- if (!peer_dev->gpu)
+ if (!peer_dev || !peer_dev->gpu)
continue;
if (peer_dev->gpu->hive_id != kdev->hive_id)
continue;
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: fix potential null pointer dereference on pointer peer_dev
2019-06-29 13:31 [PATCH] drm/amdkfd: fix potential null pointer dereference on pointer peer_dev Colin King
@ 2019-07-02 15:29 ` Liu, Shaoyun
2019-07-02 18:24 ` Kuehling, Felix
0 siblings, 1 reply; 3+ messages in thread
From: Liu, Shaoyun @ 2019-07-02 15:29 UTC (permalink / raw)
To: Colin King, Oded Gabbay, Deucher, Alexander, Koenig, Christian,
Zhou, David(ChunMing),
David Airlie, Daniel Vetter, dri-devel, amd-gfx
Cc: kernel-janitors, linux-kernel
From the comments , "we will loop GPUs that already be processed (with
lower value of proximity_domain) ", the device should already been
added into the topology_device_list. So in this case ,
kfd_topology_device_by_proximity_domain will not return a NULL pointer.
If you really get the null pointer dereferences here , we must have
some bigger problem and can not solved by added the null check here.
Regards
shaoyun.liu
On 2019-06-29 9:31 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The call to kfd_topology_device_by_proximity_domain can return a NULL
> pointer so add a null pointer check on peer_dev to the existing null
> pointer check on peer_dev->gpu to avoid any potential null pointer
> dereferences.
>
> Addresses-Coverity: ("Dereference on null return value")
> Fixes: ae9a25aea7f3 ("drm/amdkfd: Generate xGMI direct iolink")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> index 4e3fc284f6ac..cb6b46cfa6c2 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> @@ -1293,7 +1293,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
> if (kdev->hive_id) {
> for (nid = 0; nid < proximity_domain; ++nid) {
> peer_dev = kfd_topology_device_by_proximity_domain(nid);
> - if (!peer_dev->gpu)
> + if (!peer_dev || !peer_dev->gpu)
> continue;
> if (peer_dev->gpu->hive_id != kdev->hive_id)
> continue;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: fix potential null pointer dereference on pointer peer_dev
2019-07-02 15:29 ` Liu, Shaoyun
@ 2019-07-02 18:24 ` Kuehling, Felix
0 siblings, 0 replies; 3+ messages in thread
From: Kuehling, Felix @ 2019-07-02 18:24 UTC (permalink / raw)
To: Liu, Shaoyun, Colin King, Oded Gabbay, Deucher, Alexander,
Koenig, Christian, Zhou, David(ChunMing),
David Airlie, Daniel Vetter, dri-devel, amd-gfx
Cc: kernel-janitors, linux-kernel
I think this could happen if KFD initialization fails for a device.
Currently we'd add the device, and then remove it again. That may leave
a gap in the proximity domains. Oak just had a fix recently to clean
that up by only adding KFD devices to the topology after successful
initialization.
Regards,
Felix
On 2019-07-02 11:29 a.m., Liu, Shaoyun wrote:
> From the comments , "we will loop GPUs that already be processed (with
> lower value of proximity_domain) ", the device should already been
> added into the topology_device_list. So in this case ,
> kfd_topology_device_by_proximity_domain will not return a NULL pointer.
> If you really get the null pointer dereferences here , we must have
> some bigger problem and can not solved by added the null check here.
>
> Regards
>
> shaoyun.liu
>
> On 2019-06-29 9:31 a.m., Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The call to kfd_topology_device_by_proximity_domain can return a NULL
>> pointer so add a null pointer check on peer_dev to the existing null
>> pointer check on peer_dev->gpu to avoid any potential null pointer
>> dereferences.
>>
>> Addresses-Coverity: ("Dereference on null return value")
>> Fixes: ae9a25aea7f3 ("drm/amdkfd: Generate xGMI direct iolink")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
>> index 4e3fc284f6ac..cb6b46cfa6c2 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
>> @@ -1293,7 +1293,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
>> if (kdev->hive_id) {
>> for (nid = 0; nid < proximity_domain; ++nid) {
>> peer_dev = kfd_topology_device_by_proximity_domain(nid);
>> - if (!peer_dev->gpu)
>> + if (!peer_dev || !peer_dev->gpu)
>> continue;
>> if (peer_dev->gpu->hive_id != kdev->hive_id)
>> continue;
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-02 18:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-29 13:31 [PATCH] drm/amdkfd: fix potential null pointer dereference on pointer peer_dev Colin King
2019-07-02 15:29 ` Liu, Shaoyun
2019-07-02 18:24 ` Kuehling, Felix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®