[PATCH libdrm] Make sure the second argument to container_of() is initialized

Alex Deucher alexdeucher at gmail.com
Tue Aug 2 14:29:30 UTC 2016


On Tue, Aug 2, 2016 at 6:08 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Fixes warnings and miscompilation resulting in crashes with clang.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94249
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  amdgpu/amdgpu_vamgr.c |  2 +-
>  util_double_list.h    | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
> index 8a707cb..3eaef70 100644
> --- a/amdgpu/amdgpu_vamgr.c
> +++ b/amdgpu/amdgpu_vamgr.c
> @@ -157,7 +157,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
>  drm_private void
>  amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size)
>  {
> -       struct amdgpu_bo_va_hole *hole;
> +       struct amdgpu_bo_va_hole *hole = NULL;
>
>         if (va == AMDGPU_INVALID_VA_ADDRESS)
>                 return;
> diff --git a/util_double_list.h b/util_double_list.h
> index 5d01f52..fc32da5 100644
> --- a/util_double_list.h
> +++ b/util_double_list.h
> @@ -114,29 +114,29 @@ static inline void list_delinit(struct list_head *item)
>  #endif
>
>  #define LIST_FOR_EACH_ENTRY(pos, head, member)                         \
> -   for (pos = container_of((head)->next, pos, member);                 \
> +   for (pos = NULL, pos = container_of((head)->next, pos, member);     \
>         &pos->member != (head);                                         \
>         pos = container_of(pos->member.next, pos, member))
>
>  #define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member)   \
> -   for (pos = container_of((head)->next, pos, member),                 \
> +   for (pos = NULL, pos = container_of((head)->next, pos, member),     \
>         storage = container_of(pos->member.next, pos, member);  \
>         &pos->member != (head);                                         \
>         pos = storage, storage = container_of(storage->member.next, storage, member))
>
>  #define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member)       \
> -   for (pos = container_of((head)->prev, pos, member),                 \
> +   for (pos = NULL, pos = container_of((head)->prev, pos, member),     \
>         storage = container_of(pos->member.prev, pos, member);          \
>         &pos->member != (head);                                         \
>         pos = storage, storage = container_of(storage->member.prev, storage, member))
>
>  #define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member)             \
> -   for (pos = container_of((start), pos, member);                      \
> +   for (pos = NULL, pos = container_of((start), pos, member);          \
>         &pos->member != (head);                                         \
>         pos = container_of(pos->member.next, pos, member))
>
>  #define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member)         \
> -   for (pos = container_of((start), pos, member);                      \
> +   for (pos = NULL, pos = container_of((start), pos, member);          \
>         &pos->member != (head);                                         \
>         pos = container_of(pos->member.prev, pos, member))
>
> --
> 2.8.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


More information about the dri-devel mailing list