diff mbox

[06/11] xf86drmSL: Check function return value

Message ID 1428655383-26087-7-git-send-email-praveen.paneri@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Praveen Paneri April 10, 2015, 8:42 a.m. UTC
Validate the return value of SLCreateEntry() before using it.

v2: Rebased to the latest.

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

Patch

diff --git a/xf86drmSL.c b/xf86drmSL.c
index a12fa1d..42b5bc4 100644
--- a/xf86drmSL.c
+++ b/xf86drmSL.c
@@ -107,6 +107,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;
@@ -173,6 +174,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++) {