aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index a86a3a5c8a19..5fc5cf50cf1b 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -233,7 +233,7 @@ static int shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
233} 233}
234 234
235#ifdef CONFIG_NUMA 235#ifdef CONFIG_NUMA
236int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new) 236static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
237{ 237{
238 struct file *file = vma->vm_file; 238 struct file *file = vma->vm_file;
239 struct shm_file_data *sfd = shm_file_data(file); 239 struct shm_file_data *sfd = shm_file_data(file);
@@ -243,7 +243,8 @@ int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
243 return err; 243 return err;
244} 244}
245 245
246struct mempolicy *shm_get_policy(struct vm_area_struct *vma, unsigned long addr) 246static struct mempolicy *shm_get_policy(struct vm_area_struct *vma,
247 unsigned long addr)
247{ 248{
248 struct file *file = vma->vm_file; 249 struct file *file = vma->vm_file;
249 struct shm_file_data *sfd = shm_file_data(file); 250 struct shm_file_data *sfd = shm_file_data(file);
@@ -906,7 +907,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
906 goto out_unlock; 907 goto out_unlock;
907 908
908 path.dentry = dget(shp->shm_file->f_path.dentry); 909 path.dentry = dget(shp->shm_file->f_path.dentry);
909 path.mnt = mntget(shp->shm_file->f_path.mnt); 910 path.mnt = shp->shm_file->f_path.mnt;
910 shp->shm_nattch++; 911 shp->shm_nattch++;
911 size = i_size_read(path.dentry->d_inode); 912 size = i_size_read(path.dentry->d_inode);
912 shm_unlock(shp); 913 shm_unlock(shp);
@@ -914,18 +915,16 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
914 err = -ENOMEM; 915 err = -ENOMEM;
915 sfd = kzalloc(sizeof(*sfd), GFP_KERNEL); 916 sfd = kzalloc(sizeof(*sfd), GFP_KERNEL);
916 if (!sfd) 917 if (!sfd)
917 goto out_put_path; 918 goto out_put_dentry;
918 919
919 err = -ENOMEM; 920 err = -ENOMEM;
920 file = get_empty_filp(); 921
922 file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations);
921 if (!file) 923 if (!file)
922 goto out_free; 924 goto out_free;
923 925
924 file->f_op = &shm_file_operations;
925 file->private_data = sfd; 926 file->private_data = sfd;
926 file->f_path = path;
927 file->f_mapping = shp->shm_file->f_mapping; 927 file->f_mapping = shp->shm_file->f_mapping;
928 file->f_mode = f_mode;
929 sfd->id = shp->id; 928 sfd->id = shp->id;
930 sfd->ns = get_ipc_ns(ns); 929 sfd->ns = get_ipc_ns(ns);
931 sfd->file = shp->shm_file; 930 sfd->file = shp->shm_file;
@@ -976,9 +975,8 @@ out_unlock:
976 975
977out_free: 976out_free:
978 kfree(sfd); 977 kfree(sfd);
979out_put_path: 978out_put_dentry:
980 dput(path.dentry); 979 dput(path.dentry);
981 mntput(path.mnt);
982 goto out_nattch; 980 goto out_nattch;
983} 981}
984 982