cgroups: move pointer dereference after check

parent a5263e59
...@@ -2124,8 +2124,8 @@ struct userns_exec_unified_attach_data { ...@@ -2124,8 +2124,8 @@ struct userns_exec_unified_attach_data {
static int cgroup_unified_attach_wrapper(void *data) static int cgroup_unified_attach_wrapper(void *data)
{ {
struct userns_exec_unified_attach_data *args = data; struct userns_exec_unified_attach_data *args = data;
uid_t nsuid = (args->conf->root_nsuid_map != NULL) ? 0 : args->conf->init_uid; uid_t nsuid;
gid_t nsgid = (args->conf->root_nsgid_map != NULL) ? 0 : args->conf->init_gid; gid_t nsgid;
int ret; int ret;
if (!args->conf || args->unified_fd < 0 || args->pid <= 0) if (!args->conf || args->unified_fd < 0 || args->pid <= 0)
...@@ -2134,6 +2134,9 @@ static int cgroup_unified_attach_wrapper(void *data) ...@@ -2134,6 +2134,9 @@ static int cgroup_unified_attach_wrapper(void *data)
if (!lxc_setgroups(0, NULL) && errno != EPERM) if (!lxc_setgroups(0, NULL) && errno != EPERM)
return log_error_errno(-1, errno, "Failed to setgroups(0, NULL)"); return log_error_errno(-1, errno, "Failed to setgroups(0, NULL)");
nsuid = (args->conf->root_nsuid_map != NULL) ? 0 : args->conf->init_uid;
nsgid = (args->conf->root_nsgid_map != NULL) ? 0 : args->conf->init_gid;
ret = setresgid(nsgid, nsgid, nsgid); ret = setresgid(nsgid, nsgid, nsgid);
if (ret < 0) if (ret < 0)
return log_error_errno(-1, errno, "Failed to setresgid(%d, %d, %d)", return log_error_errno(-1, errno, "Failed to setresgid(%d, %d, %d)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment