summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-10-20 16:58:58 -0500
committerIliyan Malchev <malchev@google.com>2011-10-20 19:37:26 -0700
commitbf3ea792d0dda2047d7876557514a9eb2c5e228a (patch)
tree696752b454324ed2c85075fb360d64f615c6e235 /camera
parent2950afb136766da122c33491f17e781794b92aaf (diff)
downloadhardware_ti_omap4xxx-bf3ea792d0dda2047d7876557514a9eb2c5e228a.zip
hardware_ti_omap4xxx-bf3ea792d0dda2047d7876557514a9eb2c5e228a.tar.gz
hardware_ti_omap4xxx-bf3ea792d0dda2047d7876557514a9eb2c5e228a.tar.bz2
CameraHAL: Return null device when device_open fails
Partial fix for b/5451993 Change-Id: I47a1a3fec21b0e6a0abb8b956642b05b3a6be107 Signed-off-by: Tyler Luu <tluu@ti.com> Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'camera')
-rw-r--r--camera/CameraHal_Module.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp
index c7d1910..5fe0c06 100644
--- a/camera/CameraHal_Module.cpp
+++ b/camera/CameraHal_Module.cpp
@@ -451,17 +451,18 @@ int camera_device_close(hw_device_t* device)
ti_dev = (ti_camera_device_t*) device;
- if (gCameraHals[ti_dev->cameraid]) {
- delete gCameraHals[ti_dev->cameraid];
- gCameraHals[ti_dev->cameraid] = NULL;
- gCamerasOpen--;
- }
+ if (ti_dev) {
+ if (gCameraHals[ti_dev->cameraid]) {
+ delete gCameraHals[ti_dev->cameraid];
+ gCameraHals[ti_dev->cameraid] = NULL;
+ gCamerasOpen--;
+ }
- if (ti_dev->base.ops) {
- free(ti_dev->base.ops);
+ if (ti_dev->base.ops) {
+ free(ti_dev->base.ops);
+ }
+ free(ti_dev);
}
- free(ti_dev);
-
done:
#ifdef HEAPTRACKER
heaptracker_free_leaked_memory();
@@ -599,13 +600,19 @@ int camera_device_open(const hw_module_t* module, const char* name,
return rv;
fail:
- if(camera_device)
+ if(camera_device) {
free(camera_device);
- if(camera_ops)
+ camera_device = NULL;
+ }
+ if(camera_ops) {
free(camera_ops);
- if(camera)
+ camera_ops = NULL;
+ }
+ if(camera) {
delete camera;
-
+ camera = NULL;
+ }
+ *device = NULL;
return rv;
}