From 5c664f4ce4110c37bd30fdedb79026780635f308 Mon Sep 17 00:00:00 2001 From: Alex Ray Date: Wed, 27 Mar 2013 14:34:03 -0700 Subject: [PATCH] libcamera2: Handle ion_alloc failures Return error when failing to allocate sensor scratch buffers in device open. Bug: 8049715 Change-Id: Ib7e05e226ab08190f4bf933f8aa06ccd44758508 --- libcamera2/ExynosCameraHWInterface2.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index 5dee2e7..82b4f1a 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -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; -- 2.20.1