summaryrefslogtreecommitdiff
path: root/libfstools/mount.c
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-11-16 20:49:23 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-11-16 21:52:36 +0000
commit77c02889177c43df8ebe07bce4d55b7f7358118f (patch)
treec7e865a50afd8bc5ad0313079e63d9450c9bb984 /libfstools/mount.c
parentd3907445b7aa9cbde70d501bd68a5e38db90c6b2 (diff)
downloadfstools-77c02889177c43df8ebe07bce4d55b7f7358118f.tar.gz
fstools: fix a couple of minor code problems
Improve error handling and fix a resource leak inside an error path. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'libfstools/mount.c')
-rw-r--r--libfstools/mount.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libfstools/mount.c b/libfstools/mount.c
index 1691ce7..3d4111f 100644
--- a/libfstools/mount.c
+++ b/libfstools/mount.c
@@ -143,8 +143,11 @@ fopivot(char *rw_root, char *ro_root)
* We can't really deal with these constraints without
* creating two new subdirectories in /overlay.
*/
- mkdir(upperdir, 0755);
- mkdir(workdir, 0755);
+ if (mkdir(upperdir, 0755) == -1 && errno != EEXIST)
+ return -1;
+
+ if (mkdir(workdir, 0755) == -1 && errno != EEXIST)
+ return -1;
if (stat(upgrade, &st) == 0)
rename(upgrade, upgrade_dest);