[PATCH 4/7] drm/amdkfd: Make kfd_lookup_process_by_pasid() well defined
Oded Gabbay
oded.gabbay at gmail.com
Sat Sep 10 15:55:13 UTC 2016
On Sat, Sep 10, 2016 at 4:31 AM, Edward O'Callaghan
<funfunctor at folklore1984.net> wrote:
> Ensure we return a NULL on the fail branch so that the call
> site may BUG_ON() it.
>
> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_process.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 4f3849a..8d78052 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -481,13 +481,14 @@ bool kfd_has_process_device_data(struct kfd_process *p)
> /* This returns with process->mutex locked. */
> struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid)
> {
> - struct kfd_process *p;
> + struct kfd_process *p, *ret_p = NULL;
> unsigned int temp;
>
> int idx = srcu_read_lock(&kfd_processes_srcu);
>
> hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
> if (p->pasid == pasid) {
> + ret_p = p;
> mutex_lock(&p->mutex);
> break;
> }
> @@ -495,5 +496,5 @@ struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid)
>
> srcu_read_unlock(&kfd_processes_srcu, idx);
>
> - return p;
> + return ret_p;
> }
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
This patch is not needed. p will always be a valid pointer on return or NULL.
Unless we hit the "p->pasid == pasid" condition, in which case p is
valid, p will always be NULL when finishing the hash_for_each_rcu
macro.
Oded
More information about the amd-gfx
mailing list