diff options
Diffstat (limited to 'lib/cache.c')
-rw-r--r-- | lib/cache.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/cache.c b/lib/cache.c index 257a41b..36566e0 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -266,11 +266,13 @@ int nl_cache_alloc_name(const char *kind, struct nl_cache **result) struct nl_cache_ops *ops; struct nl_cache *cache; - ops = nl_cache_ops_lookup(kind); + ops = nl_cache_ops_lookup_safe(kind); if (!ops) return -NLE_NOCACHE; - if (!(cache = nl_cache_alloc(ops))) + cache = nl_cache_alloc(ops); + nl_cache_ops_put(ops); + if (!cache) return -NLE_NOMEM; *result = cache; |