From d0bd3ea6240117e769c8d1f6633d6eff161a69bc Mon Sep 17 00:00:00 2001 From: manxiaoliang Date: Fri, 8 Mar 2024 07:40:06 +0000 Subject: [PATCH] INTERNAL:Fix Coverity issues This is to help fix Coverity issues in minigbm project. CIDs:222122 188451 203271 255440 Tracked-On: OAM-115814 Signed-off-by: manxiaoliang --- cros_gralloc/cros_gralloc_driver.cc | 2 +- cros_gralloc/gralloc1/cros_gralloc1_module.cc | 8 ++++---- i915.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc index 84893c86..8003c2c7 100644 --- a/cros_gralloc/cros_gralloc_driver.cc +++ b/cros_gralloc/cros_gralloc_driver.cc @@ -104,7 +104,7 @@ int32_t cros_gralloc_driver::init() } node_fd[availabe_node] = fd; - strcpy(node_name[availabe_node], version->name); + strncpy(node_name[availabe_node], version->name, name_length); availabe_node++; drmFreeVersion(version); diff --git a/cros_gralloc/gralloc1/cros_gralloc1_module.cc b/cros_gralloc/gralloc1/cros_gralloc1_module.cc index 841b15ea..9978ba82 100644 --- a/cros_gralloc/gralloc1/cros_gralloc1_module.cc +++ b/cros_gralloc/gralloc1/cros_gralloc1_module.cc @@ -471,7 +471,7 @@ int32_t CrosGralloc1::lock(buffer_handle_t bufferHandle, gralloc1_producer_usage auto error = retain(buffer_handle); if (error != GRALLOC1_ERROR_NONE) { drv_log("Retain failed"); - delete buffer_handle; + free(const_cast(buffer_handle)); return error; } bufferHandle = buffer_handle; @@ -479,7 +479,7 @@ int32_t CrosGralloc1::lock(buffer_handle_t bufferHandle, gralloc1_producer_usage drv_log("lock failed"); return CROS_GRALLOC_ERROR_BAD_HANDLE; } - delete buffer_handle; + free(const_cast(buffer_handle)); } *outData = addr[0]; @@ -575,7 +575,7 @@ int32_t CrosGralloc1::lockYCbCr(buffer_handle_t bufferHandle, auto error = retain(buffer_handle); if (error != GRALLOC1_ERROR_NONE) { drv_log("Retain failed"); - delete buffer_handle; + free(const_cast(buffer_handle)); return error; } bufferHandle = buffer_handle; @@ -584,7 +584,7 @@ int32_t CrosGralloc1::lockYCbCr(buffer_handle_t bufferHandle, return CROS_GRALLOC_ERROR_BAD_HANDLE; } driver->release(buffer_handle); - delete buffer_handle; + free(const_cast(buffer_handle)); } switch (hnd->format) { diff --git a/i915.c b/i915.c index c5b0f327..4e64e382 100644 --- a/i915.c +++ b/i915.c @@ -336,8 +336,8 @@ static int i915_add_combinations(struct driver *drv) static int i915_align_dimensions(struct bo *bo, uint32_t tiling, uint32_t *stride, uint32_t *aligned_height) { - uint32_t horizontal_alignment; - uint32_t vertical_alignment; + uint32_t horizontal_alignment = 64; + uint32_t vertical_alignment = 4; struct i915_device *i915 = bo->drv->priv; if (i915->genx10 >= 125) { horizontal_alignment = 4;