From: Lennart Poettering Date: Mon, 21 Oct 2024 19:56:05 +0000 (+0200) Subject: fs-util: always go through the unlink cleanup paths in xopenat_full() X-Git-Tag: v257-rc1~161^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=652371a3c100a74999e21d9424538d3ab4cb9b97;p=thirdparty%2Fsystemd.git fs-util: always go through the unlink cleanup paths in xopenat_full() We didn't go through it at all if label_ops_post() failed. --- diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 5994ebd4035..bbf2fea3e62 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -1186,7 +1186,7 @@ int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_ if (FLAGS_SET(xopen_flags, XO_LABEL)) { r = label_ops_post(dir_fd, path); if (r < 0) - return r; + goto error; } open_flags &= ~(O_EXCL|O_CREAT); @@ -1206,10 +1206,8 @@ int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_ -ENOTDIR)) return fd; - if (made_dir) - (void) unlinkat(dir_fd, path, AT_REMOVEDIR); - - return fd; + r = fd; + goto error; } if (FLAGS_SET(open_flags, O_CREAT) && FLAGS_SET(xopen_flags, XO_LABEL)) {