diff options
author | Ben Widawsky <benjamin.widawsky@intel.com> | 2013-12-26 16:37:00 -0800 |
---|---|---|
committer | Ben Widawsky <benjamin.widawsky@intel.com> | 2014-01-10 11:05:50 -0800 |
commit | 3d34fe24957576d77c88877ded22e8ab5d96ca4c (patch) | |
tree | fc5999aaaec552500b2fd11251560428619e09b9 | |
parent | 743372ea26ed38db3aeca4b545e867c1bc08370d (diff) |
intel: Handle malloc fails in context create
The previous code would just use the potentially unallocated variable,
which is probably okay most of the time, but not very nice to the user
of the library.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
-rw-r--r-- | intel/intel_bufmgr_gem.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 3b1f5847..ad722dd5 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3020,15 +3020,19 @@ drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr) drm_intel_context *context = NULL; int ret; + context = calloc(1, sizeof(*context)); + if (!context) + return NULL; + VG_CLEAR(create); ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create); if (ret != 0) { DBG("DRM_IOCTL_I915_GEM_CONTEXT_CREATE failed: %s\n", strerror(errno)); + free(context); return NULL; } - context = calloc(1, sizeof(*context)); context->ctx_id = create.ctx_id; context->bufmgr = bufmgr; |