From 58c515baa9c4033f0e2ab2dd24face545a396970 Mon Sep 17 00:00:00 2001 From: Jinguang Dong Date: Tue, 2 May 2017 10:20:19 +0800 Subject: hikey: Check framebuffer memory allocation Resolve the crash when the framebuffer dev malloc failed Test: Compiles and device boots up. Change-Id: Idb0d0038d351c1ac71c289799f7fd639728f40b7 --- gralloc/framebuffer_device.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gralloc') diff --git a/gralloc/framebuffer_device.cpp b/gralloc/framebuffer_device.cpp index cfc480fa..30047780 100644 --- a/gralloc/framebuffer_device.cpp +++ b/gralloc/framebuffer_device.cpp @@ -469,6 +469,12 @@ int framebuffer_device_open(hw_module_t const *module, const char *name, hw_devi /* 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 */ -- cgit v1.2.3