summaryrefslogtreecommitdiff
path: root/src/gprs.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2019-01-03 17:17:21 -0600
committerDenis Kenzior <denkenz@gmail.com>2019-01-03 17:17:21 -0600
commitc3fdf6a7c567a7507c3558a27006b6f9559493d6 (patch)
tree0d699b7df45c4c4cfa351dd7384f4fb38be3f5bb /src/gprs.c
parent7982635328a57808683ee5e72971cf249faa4157 (diff)
downloadofono-c3fdf6a7c567a7507c3558a27006b6f9559493d6.tar.gz
gprs: Fix allocation of context id
After the convertion to l_uintset, the creation of new contexts fails due to a range error being returned from l_uintset_find_unused(). The error happens because the uinset is created with a min-value of 1, but the start-value passed to l_uintset_find_unused() is initialized as 0. Reported-by: Martin Hundebøll <martin@geanix.com>
Diffstat (limited to 'src/gprs.c')
-rw-r--r--src/gprs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gprs.c b/src/gprs.c
index 7e9e5161..58a998ca 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1898,7 +1898,12 @@ static struct pri_context *add_context(struct ofono_gprs *gprs,
unsigned int id;
struct pri_context *context;
- id = l_uintset_find_unused(gprs->used_pids, gprs->last_context_id);
+ if (gprs->last_context_id)
+ id = l_uintset_find_unused(gprs->used_pids,
+ gprs->last_context_id);
+ else
+ id = l_uintset_find_unused_min(gprs->used_pids);
+
if (id > l_uintset_get_max(gprs->used_pids))
return NULL;