aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2009-04-02 19:58:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 22:05:01 -0400
commite562aebc6ccd4385cbbf24debe88ab4bb500c5b4 (patch)
treea9dee6eac97d75c688a84d5fe268b2e5a0b73e23
parent40e8a10de2c9f87e892dcd5a6f9d1b208329ffea (diff)
ipc: make shm_get_stat() more robust
shm_get_stat() assumes idr_find(&shm_ids(ns).ipcs_idr) returns "struct shmid_kernel *"; all other callers assume that it returns "struct kern_ipc_perm *". This works because "struct kern_ipc_perm" is currently the first member of "struct shmid_kernel", but it would be better to use container_of() to prevent future breakage. Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Cc: Jiri Olsa <olsajiri@gmail.com> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--ipc/shm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index f239d87e0d37..faa46da99ebe 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -555,12 +555,14 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss,
555 in_use = shm_ids(ns).in_use; 555 in_use = shm_ids(ns).in_use;
556 556
557 for (total = 0, next_id = 0; total < in_use; next_id++) { 557 for (total = 0, next_id = 0; total < in_use; next_id++) {
558 struct kern_ipc_perm *ipc;
558 struct shmid_kernel *shp; 559 struct shmid_kernel *shp;
559 struct inode *inode; 560 struct inode *inode;
560 561
561 shp = idr_find(&shm_ids(ns).ipcs_idr, next_id); 562 ipc = idr_find(&shm_ids(ns).ipcs_idr, next_id);
562 if (shp == NULL) 563 if (ipc == NULL)
563 continue; 564 continue;
565 shp = container_of(ipc, struct shmid_kernel, shm_perm);
564 566
565 inode = shp->shm_file->f_path.dentry->d_inode; 567 inode = shp->shm_file->f_path.dentry->d_inode;
566 568