Index: kernel/generic/src/cap/cap.c
===================================================================
--- kernel/generic/src/cap/cap.c	(revision ce732e7424b576553251a9ef4cfff88391a2fe24)
+++ kernel/generic/src/cap/cap.c	(revision 15d9fe658a0f05d8f11f65e26e719b38c268b096)
@@ -84,6 +84,4 @@
 
 static slab_cache_t *cap_slab;
-
-static kobject_t *cap_unpublish_locked(task_t *, cap_handle_t, kobject_type_t);
 
 static size_t caps_hash(const ht_link_t *item)
@@ -320,5 +318,10 @@
 }
 
-static kobject_t *
+/** @copydoc cap_unpublish()
+ *
+ * Can only be called internally by the capability subsytem or from a
+ * caps_apply_to_kobject_type() callback.
+ */
+kobject_t *
 cap_unpublish_locked(task_t *task, cap_handle_t handle, kobject_type_t type)
 {
@@ -361,15 +364,14 @@
 }
 
-/** Free allocated capability
- *
- * @param task    Task in which to free the capability.
- * @param handle  Capability handle.
- */
-void cap_free(task_t *task, cap_handle_t handle)
+/** @copydoc cap_free()
+ *
+ * Can only be called internally by the capability subsytem or from a
+ * caps_apply_to_kobject_type() callback.
+ */
+void cap_free_locked(task_t *task, cap_handle_t handle)
 {
 	assert(handle >= 0);
 	assert(handle < MAX_CAPS);
 
-	mutex_lock(&task->cap_info->lock);
 	cap_t *cap = cap_get(task, handle, CAP_STATE_ALLOCATED);
 
@@ -379,4 +381,15 @@
 	ra_free(task->cap_info->handles, handle, 1);
 	slab_free(cap_slab, cap);
+}
+
+/** Free allocated capability
+ *
+ * @param task    Task in which to free the capability.
+ * @param handle  Capability handle.
+ */
+void cap_free(task_t *task, cap_handle_t handle)
+{
+	mutex_lock(&task->cap_info->lock);
+	cap_free_locked(task, handle);
 	mutex_unlock(&task->cap_info->lock);
 }
