Skip to content

Commit b4188de

Browse files
Alexey Dobriyantorvalds
authored andcommitted
ipcns: make free_ipc_ns() static
Signed-off-by: Alexey Dobriyan <[email protected]> Reviewed-by: WANG Cong <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 90af90d commit b4188de

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

include/linux/ipc_namespace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
9494
#endif
9595

9696
#if defined(CONFIG_IPC_NS)
97-
extern void free_ipc_ns(struct ipc_namespace *ns);
9897
extern struct ipc_namespace *copy_ipcs(unsigned long flags,
9998
struct ipc_namespace *ns);
10099
extern void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,

ipc/namespace.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
8383
up_write(&ids->rw_mutex);
8484
}
8585

86+
static void free_ipc_ns(struct ipc_namespace *ns)
87+
{
88+
/*
89+
* Unregistering the hotplug notifier at the beginning guarantees
90+
* that the ipc namespace won't be freed while we are inside the
91+
* callback routine. Since the blocking_notifier_chain_XXX routines
92+
* hold a rw lock on the notifier list, unregister_ipcns_notifier()
93+
* won't take the rw lock before blocking_notifier_call_chain() has
94+
* released the rd lock.
95+
*/
96+
unregister_ipcns_notifier(ns);
97+
sem_exit_ns(ns);
98+
msg_exit_ns(ns);
99+
shm_exit_ns(ns);
100+
kfree(ns);
101+
atomic_dec(&nr_ipc_ns);
102+
103+
/*
104+
* Do the ipcns removal notification after decrementing nr_ipc_ns in
105+
* order to have a correct value when recomputing msgmni.
106+
*/
107+
ipcns_notify(IPCNS_REMOVED);
108+
}
109+
86110
/*
87111
* put_ipc_ns - drop a reference to an ipc namespace.
88112
* @ns: the namespace to put
@@ -108,27 +132,3 @@ void put_ipc_ns(struct ipc_namespace *ns)
108132
free_ipc_ns(ns);
109133
}
110134
}
111-
112-
void free_ipc_ns(struct ipc_namespace *ns)
113-
{
114-
/*
115-
* Unregistering the hotplug notifier at the beginning guarantees
116-
* that the ipc namespace won't be freed while we are inside the
117-
* callback routine. Since the blocking_notifier_chain_XXX routines
118-
* hold a rw lock on the notifier list, unregister_ipcns_notifier()
119-
* won't take the rw lock before blocking_notifier_call_chain() has
120-
* released the rd lock.
121-
*/
122-
unregister_ipcns_notifier(ns);
123-
sem_exit_ns(ns);
124-
msg_exit_ns(ns);
125-
shm_exit_ns(ns);
126-
kfree(ns);
127-
atomic_dec(&nr_ipc_ns);
128-
129-
/*
130-
* Do the ipcns removal notification after decrementing nr_ipc_ns in
131-
* order to have a correct value when recomputing msgmni.
132-
*/
133-
ipcns_notify(IPCNS_REMOVED);
134-
}

0 commit comments

Comments
 (0)