summaryrefslogtreecommitdiff
path: root/lib/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/object.c')
-rw-r--r--lib/object.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/object.c b/lib/object.c
index 024062e..806bae6 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -85,11 +85,13 @@ int nl_object_alloc_name(const char *kind, struct nl_object **result)
{
struct nl_cache_ops *ops;
- ops = nl_cache_ops_lookup(kind);
+ ops = nl_cache_ops_lookup_safe(kind);
if (!ops)
return -NLE_OPNOTSUPP;
- if (!(*result = nl_object_alloc(ops->co_obj_ops)))
+ *result = nl_object_alloc(ops->co_obj_ops);
+ nl_cache_ops_put(ops);
+ if (!*result)
return -NLE_NOMEM;
return 0;