aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 9fb044f3b34..02ecf2c078f 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -105,9 +105,16 @@ void shm_exit_ns(struct ipc_namespace *ns)
105} 105}
106#endif 106#endif
107 107
108void __init shm_init (void) 108static int __init ipc_ns_init(void)
109{ 109{
110 shm_init_ns(&init_ipc_ns); 110 shm_init_ns(&init_ipc_ns);
111 return 0;
112}
113
114pure_initcall(ipc_ns_init);
115
116void __init shm_init (void)
117{
111 ipc_init_proc_interface("sysvipc/shm", 118 ipc_init_proc_interface("sysvipc/shm",
112#if BITS_PER_LONG <= 32 119#if BITS_PER_LONG <= 32
113 " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n", 120 " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n",
@@ -294,7 +301,7 @@ static int shm_try_destroy_orphaned(int id, void *p, void *data)
294void shm_destroy_orphaned(struct ipc_namespace *ns) 301void shm_destroy_orphaned(struct ipc_namespace *ns)
295{ 302{
296 down_write(&shm_ids(ns).rw_mutex); 303 down_write(&shm_ids(ns).rw_mutex);
297 if (&shm_ids(ns).in_use) 304 if (shm_ids(ns).in_use)
298 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns); 305 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns);
299 up_write(&shm_ids(ns).rw_mutex); 306 up_write(&shm_ids(ns).rw_mutex);
300} 307}
@@ -304,9 +311,12 @@ void exit_shm(struct task_struct *task)
304{ 311{
305 struct ipc_namespace *ns = task->nsproxy->ipc_ns; 312 struct ipc_namespace *ns = task->nsproxy->ipc_ns;
306 313
314 if (shm_ids(ns).in_use == 0)
315 return;
316
307 /* Destroy all already created segments, but not mapped yet */ 317 /* Destroy all already created segments, but not mapped yet */
308 down_write(&shm_ids(ns).rw_mutex); 318 down_write(&shm_ids(ns).rw_mutex);
309 if (&shm_ids(ns).in_use) 319 if (shm_ids(ns).in_use)
310 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_current, ns); 320 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_current, ns);
311 up_write(&shm_ids(ns).rw_mutex); 321 up_write(&shm_ids(ns).rw_mutex);
312} 322}