diff options
Diffstat (limited to 'ipc/shm.c')
-rw-r--r-- | ipc/shm.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -105,9 +105,16 @@ void shm_exit_ns(struct ipc_namespace *ns) | |||
105 | } | 105 | } |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | void __init shm_init (void) | 108 | static 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 | |||
114 | pure_initcall(ipc_ns_init); | ||
115 | |||
116 | void __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) | |||
294 | void shm_destroy_orphaned(struct ipc_namespace *ns) | 301 | void 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 | } |