aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2022-08-17 16:00:39 +0200
committerneels <nhofmeyr@sysmocom.de>2022-08-18 14:13:28 +0000
commitd5150a61fc246879760aa722742bdfc02e1d82a5 (patch)
treee11ee7842b6e07a14bae00c03d042263d27b6e98
parent709da278cac44922c46bb57ee1a6b2555b5d6779 (diff)
use_count: Return if uc is NULL
The documentation for osmo_use_count_get_put states the return value is "Negative on range violations or USE_LIST == NULL, the use_cb()'s return value, or 0 on success" However, the code in _osmo_use_count_get_put doesn't check if uc is NULL - instead it would crash in osmo_use_count_find() where it is dereferenced. Add a check for uc and return -EINVAL if it is NULL. Change-Id: I792563696860a3100e95cafdd5fe57511819ef56 Related: SYS#5895
-rw-r--r--src/use_count.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/use_count.c b/src/use_count.c
index 6c528991..9714403d 100644
--- a/src/use_count.c
+++ b/src/use_count.c
@@ -235,6 +235,8 @@ int _osmo_use_count_get_put(struct osmo_use_count *uc, const char *use, int32_t
{
struct osmo_use_count_entry *e;
int32_t old_use_count;
+ if (!uc)
+ return -EINVAL;
if (!change)
return 0;