cache: make sure the user has specified a callback

In cache_include(), the user callback is used even though one might not
have been specified, leading to a crash. This happens, for example, when
NetworkManager calls nl_cache_include() with the change_cb argument set
to NULL. Fix it by making sure the callback points to a valid address.

Signed-off-by: Mihai Dontu <mihai.dontu@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
mihai.dontu@gmail.com 2013-01-06 07:07:02 +02:00 committed by Thomas Graf
parent 00a5879e6e
commit ba38f39198

View file

@ -752,7 +752,8 @@ static int cache_include(struct nl_cache *cache, struct nl_object *obj,
* Handle them first.
*/
if (nl_object_update(old, obj) == 0) {
cb(cache, old, NL_ACT_CHANGE, data);
if (cb)
cb(cache, old, NL_ACT_CHANGE, data);
nl_object_put(old);
return 0;
}