diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-14 16:24:54 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-14 16:24:54 +0000 |
commit | 6a8188bb4dd0eba58e29803566023ad5c3d4d58a (patch) | |
tree | 680dd693c3fea7a9a86bb83fde8f7369c1915a4e | |
parent | 43a22743124a83310379122d509c35840b583b2e (diff) |
sna: Close any handles after bo allocation failures
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 65b600e0..fbff0514 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1415,7 +1415,13 @@ struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size) return NULL; DBG(("%s: new handle=%d\n", __FUNCTION__, handle)); - return __kgem_bo_alloc(handle, size); + bo = __kgem_bo_alloc(handle, size); + if (bo == NULL) { + gem_close(kgem->fd, size); + return NULL; + } + + return bo; } int kgem_choose_tiling(struct kgem *kgem, int tiling, int width, int height, int bpp) @@ -2600,6 +2606,10 @@ kgem_replace_bo(struct kgem *kgem, return NULL; dst = __kgem_bo_alloc(handle, size); + if (dst== NULL) { + gem_close(kgem->fd, handle); + return NULL; + } } dst->pitch = pitch; dst->unique_id = kgem_get_unique_id(kgem); |