[PATCH] drm/amdkfd: Drop redundant NULL pointer check in kfd_topology.c
Felix Kuehling
felix.kuehling at amd.com
Thu Dec 21 18:21:00 UTC 2023
On 2023-12-20 21:00, Srinivasan Shanmugam wrote:
> The list has the head node, the NULL pointer check is therefore
> superfluous, Hence removed it.
>
> Fixes the below:
> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1347 kfd_create_indirect_link_prop() warn: can 'gpu_link' even be NULL?
> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1428 kfd_add_peer_prop() warn: can 'iolink1' even be NULL?
> drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1433 kfd_add_peer_prop() warn: can 'iolink2' even be NULL?
>
> Cc: Felix Kuehling <Felix.Kuehling at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index dc7c8312e8c7..141a8b3273c8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1344,8 +1344,6 @@ static int kfd_create_indirect_link_prop(struct kfd_topology_device *kdev, int g
>
> gpu_link = list_first_entry(&kdev->io_link_props,
> struct kfd_iolink_properties, list);
> - if (!gpu_link)
> - return -ENOMEM;
I think the problem here is that list_first_entry expects the list to
not be empty. So the correct solution would be to add a !list_empty
check before using list_first_entry.
Regards,
Felix
>
> for (i = 0; i < num_cpu; i++) {
> /* CPU <--> GPU */
> @@ -1425,13 +1423,9 @@ static int kfd_add_peer_prop(struct kfd_topology_device *kdev,
>
> iolink1 = list_first_entry(&kdev->io_link_props,
> struct kfd_iolink_properties, list);
> - if (!iolink1)
> - return -ENOMEM;
>
> iolink2 = list_first_entry(&peer->io_link_props,
> struct kfd_iolink_properties, list);
> - if (!iolink2)
> - return -ENOMEM;
>
> props = kfd_alloc_struct(props);
> if (!props)
More information about the amd-gfx
mailing list