Commit f6303de7 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

sysctl: Don't forget to close fds

In case if openat/open call returned fd = 0,
don't forget to close it on routine exit,
ie just use close_safe macro.

Not a big deal since the descriptors get closed
once program finish execution but still.

#CID 996183 Resource leak
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a520b1b8
...@@ -209,8 +209,7 @@ static int __sysctl_op(int dir, struct sysctl_req *req, int op) ...@@ -209,8 +209,7 @@ static int __sysctl_op(int dir, struct sysctl_req *req, int op)
break; break;
} }
if (fd > 0) close_safe(&fd);
close(fd);
return ret; return ret;
} }
...@@ -235,7 +234,7 @@ int sysctl_op(struct sysctl_req *req, int op) ...@@ -235,7 +234,7 @@ int sysctl_op(struct sysctl_req *req, int op)
req++; req++;
} }
if (dir > 0) close_safe(&dir);
close(dir);
return ret; return ret;
} }
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