Commit 6d97c097 authored by Huang Qiang's avatar Huang Qiang Committed by Pavel Emelyanov

ipc_ns: close file immediately when we don't need it

According to Andrew's advice, change the close file logic a bit, to
make the code seems more readable.
Signed-off-by: 's avatarHuang Qiang <h.huangqiang@huawei.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7d8ad0bc
......@@ -876,10 +876,10 @@ static int prepare_ipc_var(int pid)
return -1;
ret = pb_read_one(fd, &var, PB_IPCNS_VAR);
close_safe(&fd);
if (ret <= 0) {
pr_err("Failed to read IPC namespace variables\n");
ret = -EFAULT;
goto err;
return -EFAULT;
}
ipc_sysctl_req(var, CTL_PRINT);
......@@ -889,13 +889,10 @@ static int prepare_ipc_var(int pid)
if (ret < 0) {
pr_err("Failed to prepare IPC namespace variables\n");
ret = -EFAULT;
goto err;
return -EFAULT;
}
return close_safe(&fd);
err:
close_safe(&fd);
return ret;
return 0;
}
int prepare_ipc_ns(int pid)
......
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