diff options
author | Davidlohr Bueso <davidlohr.bueso@hp.com> | 2013-09-11 17:26:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-18 10:45:47 -0400 |
commit | 247ec302b53873fa13bbb413b5df982cb5d7f78f (patch) | |
tree | be41054335d86ab325e73f75de85c38a27ad99c1 /ipc | |
parent | 00c88e695ae4c001495d6768d6c91603f34aa6c7 (diff) |
ipc,shm: cleanup do_shmat pasta
commit f42569b1388b1408b574a5e93a23a663647d4181 upstream.
Clean up some of the messy do_shmat() spaghetti code, getting rid of
out_free and out_put_dentry labels. This makes shortening the critical
region of this function in the next patch a little easier to do and read.
Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/shm.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -1108,16 +1108,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, | |||
1108 | 1108 | ||
1109 | err = -ENOMEM; | 1109 | err = -ENOMEM; |
1110 | sfd = kzalloc(sizeof(*sfd), GFP_KERNEL); | 1110 | sfd = kzalloc(sizeof(*sfd), GFP_KERNEL); |
1111 | if (!sfd) | 1111 | if (!sfd) { |
1112 | goto out_put_dentry; | 1112 | path_put(&path); |
1113 | goto out_nattch; | ||
1114 | } | ||
1113 | 1115 | ||
1114 | file = alloc_file(&path, f_mode, | 1116 | file = alloc_file(&path, f_mode, |
1115 | is_file_hugepages(shp->shm_file) ? | 1117 | is_file_hugepages(shp->shm_file) ? |
1116 | &shm_file_operations_huge : | 1118 | &shm_file_operations_huge : |
1117 | &shm_file_operations); | 1119 | &shm_file_operations); |
1118 | err = PTR_ERR(file); | 1120 | err = PTR_ERR(file); |
1119 | if (IS_ERR(file)) | 1121 | if (IS_ERR(file)) { |
1120 | goto out_free; | 1122 | kfree(sfd); |
1123 | path_put(&path); | ||
1124 | goto out_nattch; | ||
1125 | } | ||
1121 | 1126 | ||
1122 | file->private_data = sfd; | 1127 | file->private_data = sfd; |
1123 | file->f_mapping = shp->shm_file->f_mapping; | 1128 | file->f_mapping = shp->shm_file->f_mapping; |
@@ -1143,7 +1148,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, | |||
1143 | addr > current->mm->start_stack - size - PAGE_SIZE * 5) | 1148 | addr > current->mm->start_stack - size - PAGE_SIZE * 5) |
1144 | goto invalid; | 1149 | goto invalid; |
1145 | } | 1150 | } |
1146 | 1151 | ||
1147 | addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate); | 1152 | addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate); |
1148 | *raddr = addr; | 1153 | *raddr = addr; |
1149 | err = 0; | 1154 | err = 0; |
@@ -1167,19 +1172,12 @@ out_nattch: | |||
1167 | else | 1172 | else |
1168 | shm_unlock(shp); | 1173 | shm_unlock(shp); |
1169 | up_write(&shm_ids(ns).rw_mutex); | 1174 | up_write(&shm_ids(ns).rw_mutex); |
1170 | |||
1171 | out: | ||
1172 | return err; | 1175 | return err; |
1173 | 1176 | ||
1174 | out_unlock: | 1177 | out_unlock: |
1175 | shm_unlock(shp); | 1178 | shm_unlock(shp); |
1176 | goto out; | 1179 | out: |
1177 | 1180 | return err; | |
1178 | out_free: | ||
1179 | kfree(sfd); | ||
1180 | out_put_dentry: | ||
1181 | path_put(&path); | ||
1182 | goto out_nattch; | ||
1183 | } | 1181 | } |
1184 | 1182 | ||
1185 | SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg) | 1183 | SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg) |