libcamera2: Handle ion_alloc failures
authorAlex Ray <aray@google.com>
Wed, 27 Mar 2013 21:34:03 +0000 (14:34 -0700)
committerAlex Ray <aray@google.com>
Wed, 27 Mar 2013 21:35:05 +0000 (14:35 -0700)
Return error when failing to allocate sensor scratch buffers in device
open.

Bug: 8049715
Change-Id: Ib7e05e226ab08190f4bf933f8aa06ccd44758508

libcamera2/ExynosCameraHWInterface2.cpp

index 5dee2e785dc5e84a97e44b7969897080141bcaa1..82b4f1afddbd5510f996ca6b092810e9804bc7f1 100644 (file)
@@ -1277,10 +1277,19 @@ int ExynosCameraHWInterface2::InitializeISPChain()
     m_camera_info.sensor.memory = V4L2_MEMORY_DMABUF;
 
     for(i = 0; i < m_camera_info.sensor.buffers; i++){
+        int res;
         initCameraMemory(&m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes);
         m_camera_info.sensor.buffer[i].size.extS[0] = m_camera_info.sensor.width*m_camera_info.sensor.height*2;
         m_camera_info.sensor.buffer[i].size.extS[1] = 8*1024; // HACK, driver use 8*1024, should be use predefined value
-        allocCameraMemory(m_ionCameraClient, &m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes, 1<<1);
+        res = allocCameraMemory(m_ionCameraClient, &m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes, 1<<1);
+        if (res) {
+            ALOGE("ERROR(%s): failed to allocateCameraMemory for sensor buffer %d", __FUNCTION__, i);
+            // Free allocated sensor buffers
+            for (int j = 0; j < i; j++) {
+                freeCameraMemory(&m_camera_info.sensor.buffer[j], m_camera_info.sensor.planes);
+            }
+            return false;
+        }
     }
 
     m_camera_info.isp.width = m_camera_info.sensor.width;