summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-09-12 12:36:37 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2018-09-13 11:45:44 +0200
commit974bd2a0431e1369e032ccb5b7cdab5d9a8932da (patch)
treec527e1ecac2506582f1e482d6e7f882716686320
parent4cc40423d95af9b97442a63ad6f550607b7d1467 (diff)
downloadcrash-worker-974bd2a0431e1369e032ccb5b7cdab5d9a8932da.tar.gz
crash-worker-974bd2a0431e1369e032ccb5b7cdab5d9a8932da.tar.bz2
crash-worker-974bd2a0431e1369e032ccb5b7cdab5d9a8932da.zip
Fix Coverity warnings: #1020601 #1020599 #1020595 #1020587
Change-Id: I6cd513db97ad4f67f259f11e088be3e68c8dc319
-rw-r--r--src/crash-stack/crash-stack.c11
-rw-r--r--src/crash-stack/mem_map.c6
2 files changed, 10 insertions, 7 deletions
diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c
index 99f60b3..bf1cd38 100644
--- a/src/crash-stack/crash-stack.c
+++ b/src/crash-stack/crash-stack.c
@@ -118,6 +118,7 @@ static int __get_registers_fd(pid_t pid, int fd)
struct elf_prstatus *prstatus = NULL; ///< NT_PRSTATUS of the failed process
size_t size = 0;
char *registers = _crash_stack_get_memory_for_registers(&size);
+ int ret = -1;
if (NULL == registers) {
_E("Cannot get memory for registers (not implemented for this architecture");
@@ -130,12 +131,14 @@ static int __get_registers_fd(pid_t pid, int fd)
if (prstatus == MAP_FAILED)
return -1;
- if (prstatus->pr_pid != pid)
- return -1;
+ if (prstatus->pr_pid == pid) {
+ memcpy(registers, prstatus->pr_reg, size);
+ ret = 0;
+ }
- memcpy(registers, prstatus->pr_reg, size);
+ munmap(prstatus, sizeof(struct elf_prstatus));
- return 0;
+ return ret;
}
/**
diff --git a/src/crash-stack/mem_map.c b/src/crash-stack/mem_map.c
index 3a0d463..e3c48f5 100644
--- a/src/crash-stack/mem_map.c
+++ b/src/crash-stack/mem_map.c
@@ -376,7 +376,7 @@ static int mem_region_map_file(struct mem_region *region)
region->data_head->data = data;
region->data_head->length = length;
- region->data_index = malloc(sizeof(struct mem_data_chunk**));
+ region->data_index = malloc(sizeof(struct mem_data_chunk*));
if (region->data_index == NULL){
_E("Unable to allocate memory:%m");
free(region->data_head);
@@ -401,7 +401,7 @@ static int mem_region_init_vdso(struct mem_region *region)
if ((region->data_head->data = (char *)get_vdso()) == NULL)
return -1;
- region->data_index = malloc(sizeof(struct mem_data_chunk**));
+ region->data_index = malloc(sizeof(struct mem_data_chunk*));
if (region->data_index == NULL) {
_E("Unable to allocate memory:%m");
return -1;
@@ -425,7 +425,7 @@ static int mem_region_init_vsyscall(struct mem_region *region)
region->data_head->start = region->start;
region->data_head->data = (char *)VSYSCALL_START;
region->data_head->length = region->length;
- region->data_index = malloc(sizeof(struct mem_data_chunk**));
+ region->data_index = malloc(sizeof(struct mem_data_chunk*));
if (region->data_index == NULL) {
_E("Unable to allocate memory:%m");
return -1;