From b864a841e5a459a66a890c22b3a34127cd226238 Mon Sep 17 00:00:00 2001 From: popcornmix Date: Wed, 8 Jul 2015 18:39:55 +0100 Subject: [PATCH] vchiq: Better error handling Fix the user library to avoid a seg-fault on a duplicate service error, and ensure that errors in the errors in the vchiq_test functional test cause the test to stop. --- interface/vchiq_arm/vchiq_lib.c | 3 ++- interface/vchiq_arm/vchiq_test.c | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/interface/vchiq_arm/vchiq_lib.c b/interface/vchiq_arm/vchiq_lib.c index 2ba8c1da1..0efe7c97c 100755 --- a/interface/vchiq_arm/vchiq_lib.c +++ b/interface/vchiq_arm/vchiq_lib.c @@ -1669,7 +1669,8 @@ create_service(VCHIQ_INSTANCE_T instance, { vcos_mutex_lock(&instance->mutex); - service->lib_handle = VCHIQ_SERVICE_HANDLE_INVALID; + if (service) + service->lib_handle = VCHIQ_SERVICE_HANDLE_INVALID; vcos_mutex_unlock(&instance->mutex); diff --git a/interface/vchiq_arm/vchiq_test.c b/interface/vchiq_arm/vchiq_test.c index 4e89d2e16..9a69fa144 100644 --- a/interface/vchiq_arm/vchiq_test.c +++ b/interface/vchiq_arm/vchiq_test.c @@ -1273,6 +1273,7 @@ func_data_test(VCHIQ_SERVICE_HANDLE_T service, int datalen, int align, int serve { vcos_log_error("%d: Data corrupted at %x-%x (datalen %x, align %x, server_align %x) -> %02x", func_data_test_iter, i - diffs, i - 1, datalen, align, server_align, data[i-1]); VCOS_BKPT; + success = 0; diffs = 0; } } @@ -1280,12 +1281,16 @@ func_data_test(VCHIQ_SERVICE_HANDLE_T service, int datalen, int align, int serve { vcos_log_error("%d: Data corrupted at %x-%x (datalen %x, align %x, server_align %x) -> %02x", func_data_test_iter, i - diffs, i - 1, datalen, align, server_align, data[i-1]); VCOS_BKPT; + success = 0; } } skip_iter: - func_data_test_iter++; - return VCHIQ_SUCCESS; + if (success) + { + func_data_test_iter++; + return VCHIQ_SUCCESS; + } error_exit: return VCHIQ_ERROR;