From 75ee75c2115109c1385677c8a92f8ace27a48b60 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jul 2011 15:43:48 +0900 Subject: protect against NULL handle --- gralloc_drm.c | 5 ++++- gralloc_drm_handle.h | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gralloc_drm.c b/gralloc_drm.c index 0e0943b..d67561f 100644 --- a/gralloc_drm.c +++ b/gralloc_drm.c @@ -259,8 +259,11 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_register(struct gralloc_drm_t *drm, { struct gralloc_drm_handle_t *handle = gralloc_drm_handle(_handle); + if (!handle) + return NULL; + /* the buffer handle is passed to a new process */ - if (handle && unlikely(handle->data_owner != gralloc_drm_pid)) { + if (unlikely(handle->data_owner != gralloc_drm_pid)) { struct gralloc_drm_bo_t *bo; if (!create) diff --git a/gralloc_drm_handle.h b/gralloc_drm_handle.h index 343ace0..383719e 100644 --- a/gralloc_drm_handle.h +++ b/gralloc_drm_handle.h @@ -51,10 +51,10 @@ static inline struct gralloc_drm_handle_t *gralloc_drm_handle(buffer_handle_t _h struct gralloc_drm_handle_t *handle = (struct gralloc_drm_handle_t *) _handle; - if (handle->base.version != sizeof(handle->base) || - handle->base.numInts != GRALLOC_DRM_HANDLE_NUM_INTS || - handle->base.numFds != GRALLOC_DRM_HANDLE_NUM_FDS || - handle->magic != GRALLOC_DRM_HANDLE_MAGIC) + if (handle && (handle->base.version != sizeof(handle->base) || + handle->base.numInts != GRALLOC_DRM_HANDLE_NUM_INTS || + handle->base.numFds != GRALLOC_DRM_HANDLE_NUM_FDS || + handle->magic != GRALLOC_DRM_HANDLE_MAGIC)) handle = NULL; return handle; -- cgit v1.1