lib: Fix Free Pointer dereference in lib/filter.c

Coverity Scan ID 23056. access is accessed after free in access_list_delete

Signed-off-by: Denil Vira <denil@cumulusnetworks.com>
diff --git a/lib/filter.c b/lib/filter.c
index 96605c7..a472941 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -493,13 +493,13 @@
 
   filter_free (filter);
 
-  /* If access_list becomes empty delete it from access_master. */
-  if (access_list_empty (access))
-    access_list_delete (access);
-
   /* Run hook function. */
   if (master->delete_hook)
     (*master->delete_hook) (access);
+
+  /* If access_list becomes empty delete it from access_master. */
+  if (access_list_empty (access))
+    access_list_delete (access);
 }
 
 /*