chiark / gitweb /
cryptsetup-generator: add a missing OOM check
authorLennart Poettering <lennart@poettering.net>
Mon, 25 Mar 2013 22:49:13 +0000 (23:49 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 Mar 2013 22:49:13 +0000 (23:49 +0100)
src/cryptsetup/cryptsetup-generator.c

index 0a51db8..5c4a280 100644 (file)
@@ -169,8 +169,6 @@ static int create_disk(
                 }
 
                 free(to);
-                to = NULL;
-
                 if (!nofail)
                         to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
                 else
@@ -183,12 +181,13 @@ static int create_disk(
                         log_error("Failed to create symlink '%s' to '%s': %m", from, to);
                         return -errno;
                 }
-
-                free(to);
-                to = NULL;
         }
 
         e = unit_name_escape(name);
+        if (!e)
+                return log_oom();
+
+        free(to);
         to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
         if (!to)
                 return log_oom();