block: fix two resources leaks discovered by Coverity
authorDaniel Golle <daniel@makrotopia.org>
Sat, 14 Aug 2021 17:30:48 +0000 (18:30 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 14 Aug 2021 17:53:21 +0000 (18:53 +0100)
Coverity CID: 1412456 Resource leak
Coverity CID: 1412458 Resource leak

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
block.c

diff --git a/block.c b/block.c
index d8398380533447d9fc2c76acf6f82db514a55d47..9f5cebf28f5adddbf42791fa9b6b00bff11b567b 100644 (file)
--- a/block.c
+++ b/block.c
@@ -931,6 +931,8 @@ static int handle_mount(const char *source, const char *target,
                err = exec_mount(source, target, fstype, mount_opts);
        }
 
+       free(mount_opts);
+
        return err;
 }
 
@@ -1131,9 +1133,10 @@ static int umount_device(char *path, int type, bool all)
 
        if (!mp)
                return -1;
-       if (!strcmp(mp, "/") && !all)
+       if (!strcmp(mp, "/") && !all) {
+               free(mp);
                return 0;
-
+       }
        if (type != TYPE_AUTOFS)
                blockd_notify("umount", basename(path), NULL, NULL);