diff options
author | Ramkumar Radhakrishnan <ramkumar@codeaurora.org> | 2014-01-31 20:03:01 -0800 |
---|---|---|
committer | Ramkumar Radhakrishnan <ramkumar@codeaurora.org> | 2014-02-18 12:39:21 -0800 |
commit | 36bd527bc8a2abba8a003879c46f76bc5cfcdca6 (patch) | |
tree | c25bb70de25270487212e89a1f3b7f794f67986a /libgralloc/framebuffer.cpp | |
parent | ec6bd69a1c7be2a7108c7e77907da2e845663cb5 (diff) | |
download | android_hardware_qcom_display-36bd527bc8a2abba8a003879c46f76bc5cfcdca6.tar.gz android_hardware_qcom_display-36bd527bc8a2abba8a003879c46f76bc5cfcdca6.tar.bz2 android_hardware_qcom_display-36bd527bc8a2abba8a003879c46f76bc5cfcdca6.zip |
display: Remove klockwork warnings and errors.
Remove all klockwork warnings and errors for libgralloc,
libhwcomposer, liboverlay, libqdutils, libqservice, libvirtual,
libexternal libraries to avoid buffer overflow and memory leaks.
Change-Id: I078143bcbcf5e4b342156bd8305a644566f7cc4b
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 */ |