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) ...@@ -876,10 +876,10 @@ static int prepare_ipc_var(int pid)
return -1; return -1;
ret = pb_read_one(fd, &var, PB_IPCNS_VAR); ret = pb_read_one(fd, &var, PB_IPCNS_VAR);
close_safe(&fd);
if (ret <= 0) { if (ret <= 0) {
pr_err("Failed to read IPC namespace variables\n"); pr_err("Failed to read IPC namespace variables\n");
ret = -EFAULT; return -EFAULT;
goto err;
} }
ipc_sysctl_req(var, CTL_PRINT); ipc_sysctl_req(var, CTL_PRINT);
...@@ -889,13 +889,10 @@ static int prepare_ipc_var(int pid) ...@@ -889,13 +889,10 @@ static int prepare_ipc_var(int pid)
if (ret < 0) { if (ret < 0) {
pr_err("Failed to prepare IPC namespace variables\n"); pr_err("Failed to prepare IPC namespace variables\n");
ret = -EFAULT; return -EFAULT;
goto err;
} }
return close_safe(&fd);
err: return 0;
close_safe(&fd);
return ret;
} }
int prepare_ipc_ns(int pid) 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