[PATCH] cache: make sure the user has specified a callback

Mihai Donțu mihai.dontu at gmail.com
Sun Jan 6 00:07:02 EST 2013


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 at gmail.com>

---
 lib/cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/cache.c b/lib/cache.c
index 883aa51..42c0b5e 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -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;
 			}
--
1.8.1




More information about the libnl mailing list