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>
This commit is contained in:
Thomas Haller 2014-11-24 19:04:50 +01:00
parent 60ad8251f8
commit 77771ba26f

View File

@ -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);