exec: Simplify remove_arg_zero() error path

We don't need the "out" label any more, so remove "ret" and return
directly on error.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org
This commit is contained in:
Kees Cook 2024-03-09 13:46:30 -08:00
parent 1710742994
commit 725d502612
1 changed files with 3 additions and 7 deletions

View File

@ -1720,7 +1720,6 @@ static int prepare_binprm(struct linux_binprm *bprm)
*/ */
int remove_arg_zero(struct linux_binprm *bprm) int remove_arg_zero(struct linux_binprm *bprm)
{ {
int ret = 0;
unsigned long offset; unsigned long offset;
char *kaddr; char *kaddr;
struct page *page; struct page *page;
@ -1731,10 +1730,8 @@ int remove_arg_zero(struct linux_binprm *bprm)
do { do {
offset = bprm->p & ~PAGE_MASK; offset = bprm->p & ~PAGE_MASK;
page = get_arg_page(bprm, bprm->p, 0); page = get_arg_page(bprm, bprm->p, 0);
if (!page) { if (!page)
ret = -EFAULT; return -EFAULT;
goto out;
}
kaddr = kmap_local_page(page); kaddr = kmap_local_page(page);
for (; offset < PAGE_SIZE && kaddr[offset]; for (; offset < PAGE_SIZE && kaddr[offset];
@ -1748,8 +1745,7 @@ int remove_arg_zero(struct linux_binprm *bprm)
bprm->p++; bprm->p++;
bprm->argc--; bprm->argc--;
out: return 0;
return ret;
} }
EXPORT_SYMBOL(remove_arg_zero); EXPORT_SYMBOL(remove_arg_zero);