[Mesa-dev] [PATCH] anv: Add missing error-checking to anv_block_pool_init

Emil Velikov emil.l.velikov at gmail.com
Tue Nov 22 15:14:08 UTC 2016


Hi Mun,

On 20 November 2016 at 11:11, Mun Gwan-gyeong <elongbug at gmail.com> wrote:
> When the allocation fails on u_vector_init(), it returns 0
> This fixes u_vector_init failure path on anv_block_pool_init
>
> CID 1394319
>
> Signed-off-by: Mun Gwan-gyeong <elongbug at gmail.com>
> ---
>  src/intel/vulkan/anv_allocator.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
> index f472213..30bbd69 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -269,8 +269,10 @@ anv_block_pool_init(struct anv_block_pool *pool,
>     if (ftruncate(pool->fd, BLOCK_POOL_MEMFD_SIZE) == -1)
>        return;
>
> -   u_vector_init(&pool->mmap_cleanups,
> -                   round_to_power_of_two(sizeof(struct anv_mmap_cleanup)), 128);
> +   if (!u_vector_init(&pool->mmap_cleanups,
> +                      round_to_power_of_two(sizeof(struct anv_mmap_cleanup)),
> +                      128))
> +      return;
>
Seems like we don't do any proper teardown in the error paths in this
function. Can you address that first ?
As-is even though we return here, we'll crash shortly after since the
error is not propagated through anv_CreateDevice().
Having a look at the function it doesn't check anv_bo_init_new() either.

At the same time we can drop the (always true) return type for
anv_queue_init() and radv_queue_init() (in src/amd/vulkan).

Most of the above will be fixes, so please include (in the commit message):
Cc: "13.0" <mesa-stable at lists.freedesktop.org>

Keeping Jason in the CC list will be nice.
Emil


More information about the mesa-dev mailing list