[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <497F8F2D.600@cybernetics.com>
Date: Tue, 27 Jan 2009 17:48:13 -0500
From: Tony Battersby <tonyb@...ernetics.com>
To: linux-kernel@...r.kernel.org
Cc: Jiri Olsa <olsajiri@...il.com>, Jiri Kosina <jkosina@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 2/2] 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@...ernetics.com>
---
--- linux-2.6.29-rc2-git3/ipc/shm.c.orig 2009-01-27 16:23:10.000000000 -0500
+++ linux-2.6.29-rc2-git3/ipc/shm.c 2009-01-27 16:24:19.000000000 -0500
@@ -551,12 +551,14 @@ static void shm_get_stat(struct ipc_name
in_use = shm_ids(ns).in_use;
for (total = 0, next_id = 0; total < in_use; next_id++) {
+ struct kern_ipc_perm *ipc;
struct shmid_kernel *shp;
struct inode *inode;
- shp = idr_find(&shm_ids(ns).ipcs_idr, next_id);
- if (shp == NULL)
+ ipc = idr_find(&shm_ids(ns).ipcs_idr, next_id);
+ if (ipc == NULL)
continue;
+ shp = container_of(ipc, struct shmid_kernel, shm_perm);
inode = shp->shm_file->f_path.dentry->d_inode;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists