diff options
Diffstat (limited to 'libgralloc/framebuffer.cpp')
-rw-r--r-- | libgralloc/framebuffer.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp index 3109303fd..a7a58dc43 100644 --- a/libgralloc/framebuffer.cpp +++ b/libgralloc/framebuffer.cpp @@ -134,12 +134,16 @@ int mapFrameBufferLocked(struct private_module_t* module) memset(&module->commit, 0, sizeof(struct mdp_display_commit)); struct fb_fix_screeninfo finfo; - if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) + if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { + close(fd); return -errno; + } struct fb_var_screeninfo info; - if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) + if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { + close(fd); return -errno; + } info.reserved[0] = 0; info.reserved[1] = 0; @@ -232,8 +236,10 @@ int mapFrameBufferLocked(struct private_module_t* module) info.yres_virtual, info.yres*2); } - if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) + if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) { + close(fd); return -errno; + } if (int(info.width) <= 0 || int(info.height) <= 0) { // the driver doesn't return that information @@ -250,6 +256,7 @@ int mapFrameBufferLocked(struct private_module_t* module) metadata.op = metadata_op_frame_rate; if (ioctl(fd, MSMFB_METADATA_GET, &metadata) == -1) { ALOGE("Error retrieving panel frame rate"); + close(fd); return -errno; } float fps = metadata.data.panel_frame_rate; @@ -289,11 +296,15 @@ int mapFrameBufferLocked(struct private_module_t* module) ); - if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) + if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { + close(fd); return -errno; + } - if (finfo.smem_len <= 0) + if (finfo.smem_len <= 0) { + close(fd); return -errno; + } module->flags = flags; module->info = info; @@ -322,6 +333,7 @@ int mapFrameBufferLocked(struct private_module_t* module) void* vaddr = mmap(0, fbSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (vaddr == MAP_FAILED) { ALOGE("Error mapping the framebuffer (%s)", strerror(errno)); + close(fd); return -errno; } module->framebuffer->base = intptr_t(vaddr); @@ -373,6 +385,10 @@ int fb_device_open(hw_module_t const* module, const char* name, /* initialize our state here */ fb_context_t *dev = (fb_context_t*)malloc(sizeof(*dev)); + if(dev == NULL) { + gralloc_close(gralloc_device); + return status; + } memset(dev, 0, sizeof(*dev)); /* initialize the procs */ |