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
This commit is contained in:
Ramkumar Radhakrishnan
2014-01-31 20:03:01 -08:00
parent ec6bd69a1c
commit 36bd527bc8
16 changed files with 102 additions and 73 deletions

View File

@@ -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 */