[Intel-gfx] [PATCH 7/9] external/drm: Check function return value

Praveen Paneri praveen.paneri at intel.com
Thu Mar 5 21:45:12 PST 2015


Validate the return value of SLCreateEntry() before using it.

Signed-off-by: Praveen Paneri <praveen.paneri at intel.com>
---
 xf86drmSL.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xf86drmSL.c b/xf86drmSL.c
index acddb54..45f3906 100644
--- a/xf86drmSL.c
+++ b/xf86drmSL.c
@@ -139,6 +139,7 @@ void *drmSLCreate(void)
     list->magic    = SL_LIST_MAGIC;
     list->level    = 0;
     list->head     = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
+    if (!list->head) return NULL;
     list->count    = 0;
 
     for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
@@ -205,6 +206,7 @@ int drmSLInsert(void *l, unsigned long key, void *value)
     }
 
     entry = SLCreateEntry(level, key, value);
+    if (!entry) return -ENOMEM;
 
 				/* Fix up forward pointers */
     for (i = 0; i <= level; i++) {
-- 
1.9.1



More information about the Intel-gfx mailing list