[06/11] xf86drmSL: Check function return value

Submitted by Praveen Paneri on April 10, 2015, 8:42 a.m.

Details

Message ID 1428655383-26087-7-git-send-email-praveen.paneri@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Praveen Paneri April 10, 2015, 8:42 a.m.
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(+)

Patch hide | download patch | download mbox

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++) {