From 8525e3a4082f88bc93f70c996577e2e48eb57d79 Mon Sep 17 00:00:00 2001
From: Alexander Sack <asac@jwsdot.com>
Date: Fri, 21 Oct 2011 00:31:39 +0200
Subject: [PATCH] avoid dangling co_major_cache reference to NL_AUTO_PROVIDE
 caches

---
 lib/cache_mngr.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c
index cfa676b..69fd4aa 100644
--- a/lib/cache_mngr.c
+++ b/lib/cache_mngr.c
@@ -372,9 +372,12 @@ void nl_cache_mngr_free(struct nl_cache_mngr *mngr)
 	if (mngr->cm_handle)
 		nl_close(mngr->cm_handle);
 
-	for (i = 0; i < mngr->cm_nassocs; i++)
-		if (mngr->cm_assocs[i].ca_cache)
+	for (i = 0; i < mngr->cm_nassocs; i++) {
+		if (mngr->cm_assocs[i].ca_cache) {
+			nl_cache_mngt_unprovide(mngr->cm_assocs[i].ca_cache);
 			nl_cache_free(mngr->cm_assocs[i].ca_cache);
+		}
+	}
 
 	free(mngr->cm_assocs);
 	free(mngr);
-- 
1.7.5.4