From be241fb25ed0a8d41a642ea811253207f88d0962 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 6 Feb 2013 16:38:12 +0000 Subject: [PATCH] sna: Free the handle after pwrite buffer allocation failure Having just allocated the handle, we need to free it if we then fail to allocate memory for the buffer. Signed-off-by: Chris Wilson --- src/sna/kgem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index af4f0a81..a02eb39b 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -5320,7 +5320,8 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, old = &bo->base; bo = buffer_alloc_with_data(num_pages(old)); if (bo == NULL) { - free(old); + old->refcnt= 0; + kgem_bo_free(kgem, old); return NULL; }