From 7287e5649b122ec134f58e157e7908e2285dfa42 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 10 Aug 2016 10:46:47 +0200 Subject: ipcpd: Fix locking problem in local IPCP A lock was not being taken to check the state, but then it was released if the state was not IPCP_NULL, resulting in a segfault. --- src/ipcpd/local/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 99580a45..a6076800 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -261,14 +261,14 @@ static int ipcp_local_bootstrap(struct dif_config * conf) return -1; } + pthread_rwlock_wrlock(&_ipcp->state_lock); + if (_ipcp->state != IPCP_INIT) { pthread_rwlock_unlock(&_ipcp->state_lock); LOG_ERR("IPCP in wrong state."); return -1; } - pthread_rwlock_wrlock(&_ipcp->state_lock); - _ipcp->state = IPCP_ENROLLED; pthread_create(&_ap_instance->sduloop, -- cgit v1.2.3