linux-user: Propagate goto fail to return
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180818190118.12911-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
1a7b2b13c9
commit
259841c153
|
@ -9016,8 +9016,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
how = SIG_SETMASK;
|
how = SIG_SETMASK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
mask = arg2;
|
mask = arg2;
|
||||||
target_to_host_old_sigset(&set, &mask);
|
target_to_host_old_sigset(&set, &mask);
|
||||||
|
@ -9044,8 +9043,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
how = SIG_SETMASK;
|
how = SIG_SETMASK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
|
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
|
||||||
return -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
|
@ -9088,8 +9086,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
how = SIG_SETMASK;
|
how = SIG_SETMASK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
|
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
|
||||||
return -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
|
@ -9379,15 +9376,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
|
|
||||||
ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n);
|
ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n);
|
ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n);
|
ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -9420,8 +9417,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
sig.set = &set;
|
sig.set = &set;
|
||||||
if (arg_sigsize != sizeof(*target_sigset)) {
|
if (arg_sigsize != sizeof(*target_sigset)) {
|
||||||
/* Like the kernel, we enforce correct size sigsets */
|
/* Like the kernel, we enforce correct size sigsets */
|
||||||
ret = -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
target_sigset = lock_user(VERIFY_READ, arg_sigset,
|
target_sigset = lock_user(VERIFY_READ, arg_sigset,
|
||||||
sizeof(*target_sigset), 1);
|
sizeof(*target_sigset), 1);
|
||||||
|
@ -9860,17 +9856,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */
|
case TARGET_SYSLOG_ACTION_READ_CLEAR: /* Read/clear msgs */
|
||||||
case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */
|
case TARGET_SYSLOG_ACTION_READ_ALL: /* Read last messages */
|
||||||
{
|
{
|
||||||
ret = -TARGET_EINVAL;
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
goto fail;
|
return -TARGET_EINVAL;
|
||||||
}
|
}
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
|
p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
ret = -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
|
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
|
||||||
unlock_user(p, arg2, arg3);
|
unlock_user(p, arg2, arg3);
|
||||||
|
@ -10215,8 +10209,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
|
|
||||||
dirp = g_try_malloc(count);
|
dirp = g_try_malloc(count);
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
ret = -TARGET_ENOMEM;
|
return -TARGET_ENOMEM;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = get_errno(sys_getdents(arg1, dirp, count));
|
ret = get_errno(sys_getdents(arg1, dirp, count));
|
||||||
|
@ -10616,7 +10609,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
arg2 ? &node : NULL,
|
arg2 ? &node : NULL,
|
||||||
NULL));
|
NULL));
|
||||||
if (is_error(ret)) {
|
if (is_error(ret)) {
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
if (arg1 && put_user_u32(cpu, arg1)) {
|
if (arg1 && put_user_u32(cpu, arg1)) {
|
||||||
return -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
|
@ -11072,8 +11065,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
||||||
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1);
|
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1);
|
||||||
if (!target_grouplist) {
|
if (!target_grouplist) {
|
||||||
ret = -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < gidsetsize; i++) {
|
for (i = 0; i < gidsetsize; i++) {
|
||||||
grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
|
grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
|
||||||
|
@ -11331,8 +11323,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
how = SIG_SETMASK;
|
how = SIG_SETMASK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -TARGET_EINVAL;
|
return -TARGET_EINVAL;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
mask = arg2;
|
mask = arg2;
|
||||||
target_to_host_old_sigset(&set, &mask);
|
target_to_host_old_sigset(&set, &mask);
|
||||||
|
@ -11380,8 +11371,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
if (!is_error(ret)) {
|
if (!is_error(ret)) {
|
||||||
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
|
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
|
||||||
if (!target_grouplist) {
|
if (!target_grouplist) {
|
||||||
ret = -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
for(i = 0;i < ret; i++)
|
for(i = 0;i < ret; i++)
|
||||||
target_grouplist[i] = tswap32(grouplist[i]);
|
target_grouplist[i] = tswap32(grouplist[i]);
|
||||||
|
@ -11401,8 +11391,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
||||||
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
|
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
|
||||||
if (!target_grouplist) {
|
if (!target_grouplist) {
|
||||||
ret = -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
for(i = 0;i < gidsetsize; i++)
|
for(i = 0;i < gidsetsize; i++)
|
||||||
grouplist[i] = tswap32(target_grouplist[i]);
|
grouplist[i] = tswap32(target_grouplist[i]);
|
||||||
|
@ -11477,20 +11466,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
#ifdef TARGET_NR_mincore
|
#ifdef TARGET_NR_mincore
|
||||||
case TARGET_NR_mincore:
|
case TARGET_NR_mincore:
|
||||||
{
|
{
|
||||||
void *a;
|
void *a = lock_user(VERIFY_READ, arg1, arg2, 0);
|
||||||
ret = -TARGET_ENOMEM;
|
|
||||||
a = lock_user(VERIFY_READ, arg1, arg2, 0);
|
|
||||||
if (!a) {
|
if (!a) {
|
||||||
goto fail;
|
return -TARGET_ENOMEM;
|
||||||
}
|
}
|
||||||
ret = -TARGET_EFAULT;
|
|
||||||
p = lock_user_string(arg3);
|
p = lock_user_string(arg3);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
goto mincore_fail;
|
ret = -TARGET_EFAULT;
|
||||||
|
} else {
|
||||||
|
ret = get_errno(mincore(a, arg2, p));
|
||||||
|
unlock_user(p, arg3, ret);
|
||||||
}
|
}
|
||||||
ret = get_errno(mincore(a, arg2, p));
|
|
||||||
unlock_user(p, arg3, ret);
|
|
||||||
mincore_fail:
|
|
||||||
unlock_user(a, arg1, 0);
|
unlock_user(a, arg1, 0);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -11956,8 +11942,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
|
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
|
||||||
else {
|
else {
|
||||||
if (!(p = lock_user_string(arg2))) {
|
if (!(p = lock_user_string(arg2))) {
|
||||||
ret = -TARGET_EFAULT;
|
return -TARGET_EFAULT;
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
|
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
|
||||||
unlock_user(p, arg2, 0);
|
unlock_user(p, arg2, 0);
|
||||||
|
@ -12599,7 +12584,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
|
||||||
qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
|
qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
|
||||||
return -TARGET_ENOSYS;
|
return -TARGET_ENOSYS;
|
||||||
}
|
}
|
||||||
fail:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue