summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-memfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-memfd.c')
-rw-r--r--src/libsystemd/sd-memfd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsystemd/sd-memfd.c b/src/libsystemd/sd-memfd.c
index cd95978ac2..112c95fb43 100644
--- a/src/libsystemd/sd-memfd.c
+++ b/src/libsystemd/sd-memfd.c
@@ -35,9 +35,11 @@ struct sd_memfd {
};
_public_ int sd_memfd_new(sd_memfd **m) {
+ struct kdbus_cmd_memfd_make cmd = {
+ .size = sizeof(struct kdbus_cmd_memfd_make),
+ };
_cleanup_close_ int kdbus = -1;
sd_memfd *n;
- int fd;
assert_return(m, -EINVAL);
@@ -45,14 +47,16 @@ _public_ int sd_memfd_new(sd_memfd **m) {
if (kdbus < 0)
return -errno;
- if (ioctl(kdbus, KDBUS_CMD_MEMFD_NEW, &fd) < 0)
+ if (ioctl(kdbus, KDBUS_CMD_MEMFD_NEW, &cmd) < 0)
return -errno;
n = new0(struct sd_memfd, 1);
- if (!n)
+ if (!n) {
+ close_nointr_nofail(cmd.fd);
return -ENOMEM;
+ }
- n->fd = fd;
+ n->fd = cmd.fd;
*m = n;
return 0;
}