File U_vaapi_Return-false-instead-assertion-fail.patch of Package intel-vaapi-driver

From 329975c63123610fc750241654a3bd18add75beb Mon Sep 17 00:00:00 2001
From: Haihao Xiang <haihao.xiang@intel.com>
Date: Tue, 12 Feb 2019 12:37:39 +0800
Subject: [PATCH] Return false instead of assertion failure

If so, the upper-layer application or library may handle the error.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
 src/intel_driver.c | 4 +++-
 src/intel_memman.c | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/intel_driver.c b/src/intel_driver.c
index 8e8c9af3..37e2fc68 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -123,7 +123,9 @@ intel_driver_init(VADriverContextP ctx)
     intel->locked = 0;
     pthread_mutex_init(&intel->ctxmutex, NULL);
 
-    intel_memman_init(intel);
+    if (!intel_memman_init(intel))
+        return false;
+
     intel->device_id = drm_intel_bufmgr_gem_get_devid(intel->bufmgr);
     intel->device_info = i965_get_device_info(intel->device_id);
 
diff --git a/src/intel_memman.c b/src/intel_memman.c
index ca86991b..c5c805c8 100644
--- a/src/intel_memman.c
+++ b/src/intel_memman.c
@@ -35,7 +35,10 @@ Bool
 intel_memman_init(struct intel_driver_data *intel)
 {
     intel->bufmgr = intel_bufmgr_gem_init(intel->fd, BATCH_SIZE);
-    assert(intel->bufmgr);
+
+    if (!intel->bufmgr)
+        return False;
+
     intel_bufmgr_gem_enable_reuse(intel->bufmgr);
 
     if (g_intel_debug_option_flags & VA_INTEL_DEBUG_OPTION_DUMP_AUB) {
@@ -50,6 +53,7 @@ intel_memman_init(struct intel_driver_data *intel)
 Bool
 intel_memman_terminate(struct intel_driver_data *intel)
 {
-    drm_intel_bufmgr_destroy(intel->bufmgr);
+    if (intel->bufmgr)
+        drm_intel_bufmgr_destroy(intel->bufmgr);
     return True;
 }