hikey: Check framebuffer memory allocation
Resolve the crash when the framebuffer dev malloc failed
Test: Compiles and device boots up.
Change-Id: Idb0d0038d351c1ac71c289799f7fd639728f40b7
diff --git a/gralloc/framebuffer_device.cpp b/gralloc/framebuffer_device.cpp
index cfc480f..3004778 100644
--- a/gralloc/framebuffer_device.cpp
+++ b/gralloc/framebuffer_device.cpp
@@ -469,6 +469,12 @@
/* initialize our state here */
framebuffer_device_t *dev = (framebuffer_device_t *)malloc(sizeof(framebuffer_device_t));
+ if (dev == NULL)
+ {
+ AERR("Error to malloc the framebuffer (%s)", strerror(errno));
+ gralloc_close(gralloc_device);
+ return -ENOMEM;
+ }
memset(dev, 0, sizeof(*dev));
/* initialize the procs */