summaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-24 16:24:56 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-24 16:24:56 +0200
commitb2a7c2e3fd3ad9e4e3d5f475d8338ed30ede358f (patch)
treeebfb6d6df0204a900aece203cad992253db0fa6d /lib/sqfs
parent9bc8200387408f02e7ff4065664b7702b29e2545 (diff)
Clenaup error handling
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/blk_proc/pthread.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/sqfs/blk_proc/pthread.c b/lib/sqfs/blk_proc/pthread.c
index b1755ce..85146da 100644
--- a/lib/sqfs/blk_proc/pthread.c
+++ b/lib/sqfs/blk_proc/pthread.c
@@ -268,6 +268,7 @@ static int queue_pump(sqfs_block_processor_t *proc, sqfs_block_t *block)
if (proc->status != 0) {
status = proc->status;
pthread_mutex_unlock(&proc->mtx);
+ free(block);
return status;
}
@@ -277,15 +278,16 @@ static int queue_pump(sqfs_block_processor_t *proc, sqfs_block_t *block)
block = NULL;
pthread_mutex_unlock(&proc->mtx);
- if (completed != NULL && (completed->flags & SQFS_BLK_IS_FRAGMENT)) {
+ if (completed == NULL)
+ return 0;
+
+ if (completed->flags & SQFS_BLK_IS_FRAGMENT) {
status = handle_fragment(proc, completed, &block);
if (status != 0) {
free(block);
- return test_and_set_status(proc, status);
- }
-
- if (block != NULL) {
+ status = test_and_set_status(proc, status);
+ } else if (block != NULL) {
pthread_mutex_lock(&proc->mtx);
proc->dequeue_id = completed->sequence_number;
block->sequence_number = proc->dequeue_id;
@@ -302,7 +304,7 @@ static int queue_pump(sqfs_block_processor_t *proc, sqfs_block_t *block)
pthread_cond_broadcast(&proc->queue_cond);
pthread_mutex_unlock(&proc->mtx);
}
- } else if (completed != NULL) {
+ } else {
status = process_completed_block(proc, completed);
if (status != 0)
@@ -316,8 +318,10 @@ static int queue_pump(sqfs_block_processor_t *proc, sqfs_block_t *block)
int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
sqfs_block_t *block)
{
- if (block->flags & ~SQFS_BLK_USER_SETTABLE_FLAGS)
+ if (block->flags & ~SQFS_BLK_USER_SETTABLE_FLAGS) {
+ free(block);
return test_and_set_status(proc, SQFS_ERROR_UNSUPPORTED);
+ }
return queue_pump(proc, block);
}
@@ -350,6 +354,7 @@ restart:
if (status != 0) {
proc->status = status;
pthread_mutex_unlock(&proc->mtx);
+ free(block);
free(it);
return status;
}
@@ -371,6 +376,8 @@ restart:
pthread_cond_broadcast(&proc->queue_cond);
goto restart;
}
+
+ free(it);
} else {
status = process_completed_block(proc, it);
free(it);