summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-11-24 18:04:50 (GMT)
committerThomas Haller <thaller@redhat.com>2014-11-25 09:44:26 (GMT)
commit77771ba26f727822274f68cedb2251abc91b39ae (patch)
treed1548f844b7367a4088bcde63eaa1a267ca9bb03
parent60ad8251f8307ee5aee2a0793a2094a7f4c410df (diff)
downloadlibnl-77771ba26f727822274f68cedb2251abc91b39ae.zip
libnl-77771ba26f727822274f68cedb2251abc91b39ae.tar.gz
libnl-77771ba26f727822274f68cedb2251abc91b39ae.tar.bz2
cache: assert in nl_cache_mngt_register() for valid oo_keygen() function
oo_keygen() requires oo_compare(). Assert in nl_cache_mngt_register(). http://lists.infradead.org/pipermail/libnl/2014-November/001759.html Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--lib/cache_mngt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c
index 9f8a742..8ed2129 100644
--- a/lib/cache_mngt.c
+++ b/lib/cache_mngt.c
@@ -254,6 +254,9 @@ int nl_cache_mngt_register(struct nl_cache_ops *ops)
if (!ops->co_name || !ops->co_obj_ops)
return -NLE_INVAL;
+ /* oo_keygen() also needs oo_compare() */
+ BUG_ON (ops->co_obj_ops->oo_keygen && !ops->co_obj_ops->oo_compare);
+
nl_write_lock(&cache_ops_lock);
if (__nl_cache_ops_lookup(ops->co_name)) {
nl_write_unlock(&cache_ops_lock);