diff options
author | Denis Kenzior <denkenz@gmail.com> | 2019-01-03 17:17:21 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2019-01-03 17:17:21 -0600 |
commit | c3fdf6a7c567a7507c3558a27006b6f9559493d6 (patch) | |
tree | 0d699b7df45c4c4cfa351dd7384f4fb38be3f5bb /src/gprs.c | |
parent | 7982635328a57808683ee5e72971cf249faa4157 (diff) | |
download | ofono-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.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |