mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 14:05:39 +00:00
ipc,shm: cleanup do_shmat pasta
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>
This commit is contained in:
parent
2caacaa82a
commit
f42569b138
26
ipc/shm.c
26
ipc/shm.c
@ -1108,16 +1108,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
|
|||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
sfd = kzalloc(sizeof(*sfd), GFP_KERNEL);
|
sfd = kzalloc(sizeof(*sfd), GFP_KERNEL);
|
||||||
if (!sfd)
|
if (!sfd) {
|
||||||
goto out_put_dentry;
|
path_put(&path);
|
||||||
|
goto out_nattch;
|
||||||
|
}
|
||||||
|
|
||||||
file = alloc_file(&path, f_mode,
|
file = alloc_file(&path, f_mode,
|
||||||
is_file_hugepages(shp->shm_file) ?
|
is_file_hugepages(shp->shm_file) ?
|
||||||
&shm_file_operations_huge :
|
&shm_file_operations_huge :
|
||||||
&shm_file_operations);
|
&shm_file_operations);
|
||||||
err = PTR_ERR(file);
|
err = PTR_ERR(file);
|
||||||
if (IS_ERR(file))
|
if (IS_ERR(file)) {
|
||||||
goto out_free;
|
kfree(sfd);
|
||||||
|
path_put(&path);
|
||||||
|
goto out_nattch;
|
||||||
|
}
|
||||||
|
|
||||||
file->private_data = sfd;
|
file->private_data = sfd;
|
||||||
file->f_mapping = shp->shm_file->f_mapping;
|
file->f_mapping = shp->shm_file->f_mapping;
|
||||||
@ -1143,7 +1148,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
|
|||||||
addr > current->mm->start_stack - size - PAGE_SIZE * 5)
|
addr > current->mm->start_stack - size - PAGE_SIZE * 5)
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate);
|
addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate);
|
||||||
*raddr = addr;
|
*raddr = addr;
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -1167,19 +1172,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
|
|||||||
else
|
else
|
||||||
shm_unlock(shp);
|
shm_unlock(shp);
|
||||||
up_write(&shm_ids(ns).rw_mutex);
|
up_write(&shm_ids(ns).rw_mutex);
|
||||||
|
|
||||||
out:
|
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
shm_unlock(shp);
|
shm_unlock(shp);
|
||||||
goto out;
|
out:
|
||||||
|
return err;
|
||||||
out_free:
|
|
||||||
kfree(sfd);
|
|
||||||
out_put_dentry:
|
|
||||||
path_put(&path);
|
|
||||||
goto out_nattch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg)
|
SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg)
|
||||||
|
Loading…
Reference in New Issue
Block a user